1 | <?php |
||
18 | class Indexable implements IndexableInterface |
||
19 | { |
||
20 | /** |
||
21 | * An array of raw configured callbacks for all types. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $callbacks = []; |
||
26 | |||
27 | /** |
||
28 | * An instance of ExpressionLanguage. |
||
29 | * |
||
30 | * @var ExpressionLanguage |
||
31 | */ |
||
32 | private $expressionLanguage; |
||
33 | |||
34 | /** |
||
35 | * An array of initialised callbacks. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $initialisedCallbacks = []; |
||
40 | |||
41 | 15 | public function __construct(array $callbacks) |
|
45 | |||
46 | /** |
||
47 | * Return whether the object is indexable with respect to the callback. |
||
48 | */ |
||
49 | 15 | public function isObjectIndexable(string $indexName, object $object): bool |
|
66 | |||
67 | /** |
||
68 | * Builds and initialises a callback. |
||
69 | * |
||
70 | * @return callable|string|ExpressionLanguage|null |
||
71 | */ |
||
72 | 15 | private function buildCallback(string $index, object $object) |
|
90 | |||
91 | /** |
||
92 | * Processes a string expression into an Expression. |
||
93 | */ |
||
94 | 8 | private function buildExpressionCallback(string $index, object $object, string $callback): Expression |
|
112 | |||
113 | /** |
||
114 | * Retreives a cached callback, or creates a new callback if one is not found. |
||
115 | * |
||
116 | * @return mixed |
||
117 | */ |
||
118 | 15 | private function getCallback(string $index, object $object) |
|
126 | |||
127 | /** |
||
128 | * Returns the ExpressionLanguage class if it is available. |
||
129 | */ |
||
130 | 8 | private function getExpressionLanguage(): ?ExpressionLanguage |
|
138 | |||
139 | /** |
||
140 | * Returns the variable name to be used to access the object when using the ExpressionLanguage |
||
141 | * component to parse and evaluate an expression. |
||
142 | * |
||
143 | * @param mixed $object |
||
144 | */ |
||
145 | 8 | private function getExpressionVar($object = null): string |
|
155 | } |
||
156 |