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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A validate() 0 9 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