1 | <?php |
||
30 | trait ReferenceTrait |
||
31 | { |
||
32 | /** |
||
33 | * refernece start chars |
||
34 | * |
||
35 | * @var string |
||
36 | * @access protected |
||
37 | */ |
||
38 | protected $ref_start = '${'; |
||
39 | |||
40 | /** |
||
41 | * reference ending chars |
||
42 | * |
||
43 | * @var string |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected $ref_end = '}'; |
||
47 | |||
48 | /** |
||
49 | * cached pattern to match |
||
50 | * |
||
51 | * @var string |
||
52 | * @access protected |
||
53 | */ |
||
54 | protected $ref_pattern = '~(\$\{((?:(?!\$\{|\}).)+?)\})~'; |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | public function setReference( |
||
75 | |||
76 | /** |
||
77 | * {@inheritDoc} |
||
78 | */ |
||
79 | public function hasReference( |
||
91 | |||
92 | /** |
||
93 | * {@inheritDoc} |
||
94 | */ |
||
95 | public function deReference(/*# string */ $subject) |
||
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | */ |
||
119 | public function deReferenceArray(&$dataArray) |
||
132 | |||
133 | /** |
||
134 | * Check dereferenced value |
||
135 | * |
||
136 | * @param mixed $value |
||
137 | * @param string $subject |
||
138 | * @param string $reference |
||
139 | * @return mixed |
||
140 | * @throws RuntimeException |
||
141 | * @access protected |
||
142 | */ |
||
143 | protected function checkValue( |
||
157 | |||
158 | /** |
||
159 | * Resolve the reference $name |
||
160 | * |
||
161 | * @param string $name |
||
162 | * @param int $loop |
||
163 | * @return mixed |
||
164 | * @throws RuntimeException if loop found |
||
165 | * @access protected |
||
166 | */ |
||
167 | protected function resolveReference(/*# string */ $name, /*# int */ $loop) |
||
189 | |||
190 | /** |
||
191 | * For unknown reference $name |
||
192 | * |
||
193 | * @param string $name |
||
194 | * @return mixed |
||
195 | * @access protected |
||
196 | */ |
||
197 | abstract protected function resolveUnknown(/*# string */ $name); |
||
198 | |||
199 | /** |
||
200 | * The real resolving method. return NULL for unknown reference |
||
201 | * |
||
202 | * @param string $name |
||
203 | * @return mixed |
||
204 | * @access protected |
||
205 | */ |
||
206 | abstract protected function getReference(/*# string */ $name); |
||
207 | } |
||
208 |