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 — 0.9 (#692)
by
unknown
02:58
created

Type::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace Respect\Validation\Rules;
3
4
use Respect\Validation\Exceptions\ComponentException;
5
6
class Type extends AbstractRule
7
{
8
    public $type;
9
    public $availableTypes = array(
10
        'array'     => 'array',
11
        'bool'      => 'boolean',
12
        'boolean'   => 'boolean',
13
        'callable'  => 'callable',
14
        'double'    => 'double',
15
        'float'     => 'double',
16
        'int'       => 'integer',
17
        'integer'   => 'integer',
18
        'null'      => 'NULL',
19
        'object'    => 'object',
20
        'resource'  => 'resource',
21
        'string'    => 'string',
22
    );
23
24 18
    public function __construct($type)
25
    {
26 18
        $lowerType = strtolower($type);
27 18
        if (!isset($this->availableTypes[$lowerType])) {
28 1
            throw new ComponentException(sprintf('"%s" is not a valid type', print_r($type, true)));
29
        }
30
31 17
        $this->type = $type;
32 17
    }
33
34 16
    public function validate($input)
35
    {
36 16
        $lowerType = strtolower($this->type);
37 16
        if ('callable' === $lowerType) {
38 1
            return is_callable($input);
39
        }
40
41 15
        return ($this->availableTypes[$lowerType] === gettype($input));
42
    }
43
}
44