1 | <?php |
||
16 | class ValueObject implements ValueObjectInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var \ReflectionClass |
||
20 | */ |
||
21 | protected $reflection; |
||
22 | |||
23 | /** |
||
24 | * @var mixed |
||
25 | */ |
||
26 | protected $value; |
||
27 | |||
28 | /** |
||
29 | * Class Constructor |
||
30 | */ |
||
31 | 108 | public function __construct($value) |
|
32 | { |
||
33 | 108 | $this->value = $value; |
|
34 | 108 | $this->reflection = new \ReflectionClass($this); |
|
35 | 108 | } |
|
36 | |||
37 | /** |
||
38 | * @return string |
||
39 | */ |
||
40 | 1 | public function getShortName() |
|
44 | |||
45 | /** |
||
46 | * @param $field |
||
47 | * @param $value |
||
48 | */ |
||
49 | 1 | public function __set($field, $value) |
|
50 | { |
||
51 | 1 | throw new \RuntimeException( |
|
52 | "You cannot set a value of a Value Object, that's the whole point!" |
||
53 | 1 | ); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | 1 | public function hash() |
|
63 | |||
64 | /** |
||
65 | * @param $object |
||
66 | * @return mixed |
||
|
|||
67 | */ |
||
68 | 1 | public function cloneObject($object) |
|
72 | |||
73 | /** |
||
74 | * @param $string |
||
75 | * @return static |
||
76 | */ |
||
77 | 1 | public static function fromString($string) |
|
81 | |||
82 | /** |
||
83 | * @return mixed |
||
84 | */ |
||
85 | 82 | public function getValue() |
|
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | 30 | public function __toString() |
|
97 | |||
98 | /** |
||
99 | * @param ValueObject $object |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function equals(ValueObject $object) |
||
106 | } |
||
107 |
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.