Completed
Push — develop ( 523088...d9cee5 )
by Baptiste
01:42
created

Primitive   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accepts() 0 3 1
A __construct() 0 7 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Argument\Type;
5
6
use Innmind\Compose\{
7
    Definition\Argument\Type,
8
    Exception\NotAPrimitiveType
9
};
10
11
final class Primitive implements Type
12
{
13
    private $function;
14
15 9
    public function __construct(string $primitive)
16
    {
17 9
        if (!function_exists('is_'.$primitive)) {
18 1
            throw new NotAPrimitiveType($primitive);
19
        }
20
21 8
        $this->function = 'is_'.$primitive;
22 8
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 6
    public function accepts($value): bool
28
    {
29 6
        return ($this->function)($value);
30
    }
31
}
32