UploadedFileImage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processImageData() 0 19 2
1
<?php
2
3
4
namespace HustleWorks\ChuteLaravel\Services;
5
6
7
use Exception;
8
use HustleWorks\Chute\ImageFile;
9
use Illuminate\Http\UploadedFile;
10
use Intervention\Image\ImageManager;
11
12
class UploadedFileImage extends ImageFile
13
{
14
    /**
15
     * @param  UploadedFile $framework_file
16
     * @return void
17
     * @throws Exception
18
     */
19
    protected function processImageData($framework_file)
20
    {
21
        /* make sure we get the object type we're expecting */
22
        if (!$framework_file instanceof UploadedFile) {
0 ignored issues
show
Bug introduced by
The class Illuminate\Http\UploadedFile does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
23
            throw new Exception('You must provide an instance of the UploadedFile class');
24
        }
25
26
        /* set up modules for gathering data */
27
        $this->stream = file_get_contents($framework_file);
28
        $image = (new ImageManager())->make($this->stream);
29
30
        /* set all remaining data points */
31
        $this->extension = $framework_file->getClientOriginalExtension();
32
        $this->size      = $framework_file->getClientSize();
33
        $this->filename  = $framework_file->getClientOriginalName();
34
        $this->mime_type = $framework_file->getClientMimeType();
35
        $this->width     = $image->width();
36
        $this->height    = $image->height();
37
    }
38
}