Skip to content

[Insight] Usage of a function in loops should be avoided - in src/Adapter/AmazonS3.php, line 180 #19

@BernardoSilva

Description

@BernardoSilva

in src/Adapter/AmazonS3.php, line 180

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

        $this->ensureBucketExists();

        $files = $this->getFiles($sourceDir);

        $batch = array();
        for ($i = 0; $i < count($files); $i++) {
            $targetFile = str_replace($sourceDir, "", $files[$i]);
            $batch[] =  $this->service->getCommand('CopyObject', array(
                'Bucket'     => $targetBucket,
                'Key'        => "{$targetDir}{$targetFile}",
                'CopySource' => "{$sourceBucket}/{$files[$i]}",

Posted from SensioLabsInsight

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions