1 | <?php |
||
7 | class BaseObject |
||
8 | { |
||
9 | private $value; |
||
10 | |||
11 | /** |
||
12 | * @return mixed |
||
13 | */ |
||
14 | 83 | public function getValue() : string |
|
15 | { |
||
16 | 83 | return $this->value; |
|
17 | } |
||
18 | |||
19 | |||
20 | 160 | protected function __construct(String $value) |
|
21 | { |
||
22 | 160 | $this->value = $value; |
|
23 | |||
24 | 160 | if (!$this->validate($this->value)) { |
|
25 | 26 | throw new InvalidDataException(); |
|
26 | } |
||
27 | 160 | } |
|
28 | |||
29 | 42 | protected function validate($value) : bool { |
|
32 | |||
33 | 67 | public function __toString() : string |
|
37 | |||
38 | 4 | public function __toInt() : int |
|
42 | } |
||
43 |