GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 870d79...a1e45f )
by Baptiste
05:29
created

PrimitiveType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 2
A __construct() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable\ValidateArgument;
5
6
use Innmind\Immutable\{
7
    ValidateArgument,
8
    Type,
9
};
10
11
final class PrimitiveType implements ValidateArgument
12
{
13
    private $function;
14
    private $type;
15
16 254
    public function __construct(string $type)
17
    {
18 254
        $this->function = 'is_'.$type;
19 254
        $this->type = $type;
20 254
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 178
    public function __invoke($value, int $position): void
26
    {
27 178
        if (call_user_func($this->function, $value) === false) {
28 23
            $given = Type::determine($value);
29
30 23
            throw new \TypeError("Argument $position must be of type {$this->type}, $given given");
31
        }
32 169
    }
33
}
34