Passed
Push — master ( bdbf41...020b56 )
by Innocent
03:17
created

SavesToAmazonS3::saveFiles()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
namespace FaithGen\SDK\Traits;
4
5
use Illuminate\Support\Facades\Storage;
6
use Illuminate\Support\Str;
7
8
trait SavesToAmazonS3
9
{
10
    use FileTraits;
11
12
    protected function saveFiles($model)
13
    {
14
        foreach ($model->images as $image) {
15
            $imageFiles = $this->getImages($model->filesDir(), $image->name, $model->getImageDimensions());
16
17
            foreach ($imageFiles as $imageFile) {
18
                Storage::disk('s3')->put(Str::of($imageFile)->after('public/'), fopen($imageFile, 'r+'), 'public');
0 ignored issues
show
Bug introduced by
It seems like fopen($imageFile, 'r+') can also be of type false; however, parameter $contents of Illuminate\Filesystem\FilesystemAdapter::put() does only seem to accept resource|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
                Storage::disk('s3')->put(Str::of($imageFile)->after('public/'), /** @scrutinizer ignore-type */ fopen($imageFile, 'r+'), 'public');
Loading history...
19
            }
20
        }
21
        $this->deleteFiles($model);
22
    }
23
}
24