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

Primitive::accepts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
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