IdentifierType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 45
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTarget() 0 3 1
A getPrimitive() 0 3 1
A is() 0 3 1
A __toString() 0 3 1
1
<?php
2
namespace rtens\domin\reflection\types;
3
4
use watoki\reflect\Type;
5
6
class IdentifierType implements Type {
7
8
    public static $CLASS = __CLASS__;
9
10
    /** @var string */
11
    private $target;
12
13
    /** @var Type */
14
    private $primitive;
15
16
    /**
17
     * @param string $target Identified class
18
     * @param Type $primitive
19
     */
20
    public function __construct($target, Type $primitive) {
21
        $this->target = trim($target, '\\');
22
        $this->primitive = $primitive;
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function getTarget() {
29
        return $this->target;
30
    }
31
32
    /**
33
     * @return \watoki\reflect\Type
34
     */
35
    public function getPrimitive() {
36
        return $this->primitive;
37
    }
38
39
    /**
40
     * @param mixed $value
41
     * @return boolean
42
     */
43
    public function is($value) {
44
        return $this->primitive->is($value);
45
    }
46
47
    public function __toString() {
48
        return $this->primitive . '|' . $this->target . '-ID';
49
    }
50
}