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
16:22 queued 11:14
created

Image::validate()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

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