1 | <?php |
||
18 | class ValueObject implements ValueObjectInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var \ReflectionClass |
||
22 | */ |
||
23 | protected $reflection; |
||
24 | |||
25 | /** |
||
26 | * @var mixed |
||
27 | */ |
||
28 | protected $value; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type; |
||
34 | |||
35 | /** |
||
36 | * Class Constructor |
||
37 | */ |
||
38 | 109 | public function __construct($value) |
|
39 | { |
||
40 | 109 | $this->value = $value; |
|
41 | 109 | $this->type = gettype($value); |
|
42 | 109 | $this->reflection = new \ReflectionClass($this); |
|
43 | 109 | } |
|
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | 1 | public function getType() |
|
49 | { |
||
50 | 1 | $phpType = gettype($this->getValue()); |
|
51 | 1 | return $phpType === 'object' ? get_class($this->getValue()) : $phpType; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function getShortName() |
|
61 | |||
62 | /** |
||
63 | * @param $field |
||
64 | * @param $value |
||
65 | * @throws \RuntimeException |
||
66 | * @return void |
||
|
|||
67 | */ |
||
68 | 1 | public function __set($field, $value) |
|
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | 1 | public function hash() |
|
82 | |||
83 | /** |
||
84 | * @param $object |
||
85 | * @return mixed |
||
86 | */ |
||
87 | 1 | public function cloneObject($object) |
|
91 | |||
92 | /** |
||
93 | * @param $string |
||
94 | * @return static |
||
95 | */ |
||
96 | public static function fromString($string) |
||
100 | |||
101 | /** |
||
102 | * @return mixed |
||
103 | */ |
||
104 | 85 | public function getValue() |
|
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | 30 | public function __toString() |
|
116 | |||
117 | /** |
||
118 | * @param ValueObject $object |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function equals(ValueObject $object) |
||
125 | |||
126 | /** |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function isArray() |
||
133 | |||
134 | /** |
||
135 | * @param ValueObject $object |
||
136 | * @return array|mixed |
||
137 | */ |
||
138 | public function diff(ValueObject $object) |
||
160 | |||
161 | public function count() |
||
180 | } |
||
181 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.