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
Push — 2.0 ( e6a123...4184ab )
by Henrique
03:41
created

Image::validate()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 16
ccs 0
cts 8
cp 0
rs 9.2
c 1
b 0
f 0
cc 4
eloc 8
nc 6
nop 1
crap 20
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
use SplFileInfo;
16
17
class Image extends AbstractRule
18
{
19
    public $fileInfo;
20
21
    public function __construct(finfo $fileInfo = null)
22
    {
23
        $this->fileInfo = $fileInfo ?: new finfo(FILEINFO_MIME_TYPE);
24
    }
25
26
    public function validate($input)
27
    {
28
        if ($input instanceof SplFileInfo) {
29
            $input = $input->getPathname();
30
        }
31
32
        if (!is_string($input)) {
33
            return false;
34
        }
35
36
        if (!is_file($input)) {
37
            return false;
38
        }
39
40
        return 0 === mb_strpos($this->fileInfo->file($input), 'image/');
41
    }
42
}
43