1 | <?php |
||
16 | class ExpandedValue |
||
17 | { |
||
18 | /** |
||
19 | * Store the original value with variables and this value will be updated in-place as it's evaluated. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $evaluated; |
||
24 | |||
25 | /** |
||
26 | * The definition of variable replacements that occurred for this specific string. |
||
27 | * |
||
28 | * The $key for the array would be the variable name without the % and the $value would be literal value that |
||
29 | * replaced the variable in the string |
||
30 | * |
||
31 | * @var string[] |
||
32 | */ |
||
33 | private $iterators; |
||
34 | |||
35 | /** |
||
36 | * ExpandedValue constructor. |
||
37 | * |
||
38 | * @param string $string |
||
39 | */ |
||
40 | 5 | public function __construct($string) |
|
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | 1 | public function __toString() |
|
52 | |||
53 | /** |
||
54 | * Get the current evaluated string. |
||
55 | * |
||
56 | * If the evaluation in FrontMatterParser hasn't been completed, this will return the partially evaluated string |
||
57 | * variables still in place. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 5 | public function getEvaluated() |
|
65 | |||
66 | /** |
||
67 | * Update the currently evaluated string. |
||
68 | * |
||
69 | * As the string is being evaluated in the FrontMatterParser, this value will be updated as variables are iterated |
||
70 | * through. |
||
71 | * |
||
72 | * @param string $string |
||
73 | */ |
||
74 | 4 | public function setEvaluated($string) |
|
78 | |||
79 | /** |
||
80 | * Get all of the variable replacements that were used in this evaluated string. |
||
81 | * |
||
82 | * @return string[] |
||
83 | */ |
||
84 | public function getIterators() |
||
85 | { |
||
86 | return $this->iterators; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Record the value of a variable replacement. |
||
91 | * |
||
92 | * The variable name should NOT contain the % and the value should be as-is |
||
93 | * |
||
94 | * @param string $variableName |
||
95 | * @param string|int $variableValue |
||
96 | */ |
||
97 | 4 | public function setIterator($variableName, $variableValue) |
|
101 | } |
||
102 |