1 | <?php |
||
23 | abstract class AbstractComponent |
||
24 | { |
||
25 | use ImmutableComponentTrait; |
||
26 | |||
27 | /** |
||
28 | * The component data |
||
29 | * |
||
30 | * @var int|string |
||
31 | */ |
||
32 | protected $data; |
||
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | 12 | public static function __set_state(array $properties) |
|
41 | |||
42 | /** |
||
43 | * new instance |
||
44 | * |
||
45 | * @param string|null $data the component value |
||
46 | */ |
||
47 | 1063 | public function __construct($data = null) |
|
48 | { |
||
49 | 1063 | if ($data !== null) { |
|
50 | 1021 | $this->init($data); |
|
51 | 606 | } |
|
52 | 958 | } |
|
53 | |||
54 | /** |
||
55 | * Set data. |
||
56 | * |
||
57 | * @param mixed $data The data to set. |
||
58 | */ |
||
59 | 1006 | protected function init($data) |
|
64 | |||
65 | /** |
||
66 | * validate the incoming data |
||
67 | * |
||
68 | * @param string $data |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 515 | protected function validate($data) |
|
79 | |||
80 | /** |
||
81 | * Returns the instance string representation; If the |
||
82 | * instance is not defined an empty string is returned |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 751 | public function __toString() |
|
90 | |||
91 | /** |
||
92 | * Returns the instance string representation |
||
93 | * with its optional URI delimiters |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 78 | public function getUriComponent() |
|
101 | |||
102 | /** |
||
103 | * Returns an instance with the specified string |
||
104 | * |
||
105 | * This method MUST retain the state of the current instance, and return |
||
106 | * an instance that contains the modified data |
||
107 | * |
||
108 | * @param string $value |
||
109 | * |
||
110 | * @return static |
||
111 | */ |
||
112 | 291 | public function modify($value) |
|
120 | } |
||
121 |