HasImageUploadTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
eloc 6
dl 0
loc 17
rs 10
c 4
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_image_file() 0 10 4
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