IdentifierType::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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