HasImageUploadTrait::get_image_file()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 4
b 1
f 0
cc 4
nc 4
nop 1
1
<?php
2
3
namespace WebDevEtc\BlogEtc\Requests\Traits;
4
5
use Illuminate\Http\UploadedFile;
6
7
trait HasImageUploadTrait
8
{
9
    /**
10
     * @param $size
11
     *
12
     * @return UploadedFile|null
13
     */
14
    public function get_image_file($size)
15
    {
16
        if ($this->file($size)) {
0 ignored issues
show
Bug introduced by
It seems like file() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

16
        if ($this->/** @scrutinizer ignore-call */ file($size)) {
Loading history...
17
            return $this->file($size);
18
        }
19
20
        // not found? lets cycle through all the images and see if anything was submitted, and use that instead
21
        foreach (config('blogetc.image_sizes') as $image_size_name => $image_size_info) {
22
            if ($this->file($image_size_name)) {
23
                return $this->file($image_size_name);
24
            }
25
        }
26
    }
27
}
28