Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#621)
by Henrique
08:20 queued 03:34
created

Image::validate()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 7
cts 9
cp 0.7778
rs 9.2
cc 4
eloc 8
nc 6
nop 1
crap 4.1755
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
use finfo;
15
16
class Image extends AbstractRule
17
{
18
    public $fileInfo;
19
20 2
    public function __construct(finfo $fileInfo = null)
21
    {
22 2
        $this->fileInfo = $fileInfo ?: new finfo(FILEINFO_MIME_TYPE);
23 2
    }
24
25 7
    public function validate($input)
26
    {
27 7
        if ($input instanceof SplFileInfo) {
0 ignored issues
show
Bug introduced by
The class Respect\Validation\Rules\SplFileInfo 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...
28
            $input = $input->getPathname();
29
        }
30
31 7
        if (!is_string($input)) {
32 2
            return false;
33
        }
34
35 5
        if (!is_file($input)) {
36 1
            return false;
37
        }
38
39 4
        return (0 === strpos($this->fileInfo->file($input), 'image/'));
40
    }
41
}
42