1 | <?php |
||
17 | abstract class ClassDiscovery |
||
18 | { |
||
19 | /** |
||
20 | * A list of strategies to find classes. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | private static $strategies = [ |
||
25 | Strategy\PuliBetaStrategy::class, |
||
26 | Strategy\CommonClassesStrategy::class, |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * Discovery cache to make the second time we use discovery faster. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | private static $cache = []; |
||
35 | |||
36 | /** |
||
37 | * Finds a class. |
||
38 | * |
||
39 | * @param string $type |
||
40 | * |
||
41 | * @return string|\Closure |
||
42 | * |
||
43 | * @throws DiscoveryFailedException |
||
44 | */ |
||
45 | protected static function findOneByType($type) |
||
85 | |||
86 | /** |
||
87 | * Get a value from cache. |
||
88 | * |
||
89 | * @param string $type |
||
90 | * |
||
91 | * @return string|null |
||
92 | */ |
||
93 | private static function getFromCache($type) |
||
108 | |||
109 | /** |
||
110 | * Store a value in cache. |
||
111 | * |
||
112 | * @param string $type |
||
113 | * @param string $class |
||
114 | */ |
||
115 | private static function storeInCache($type, $class) |
||
119 | |||
120 | /** |
||
121 | * Set new strategies and clear the cache. |
||
122 | * |
||
123 | * @param array $strategies string array of fully qualified class name to a DiscoveryStrategy |
||
124 | */ |
||
125 | public static function setStrategies(array $strategies) |
||
130 | |||
131 | /** |
||
132 | * Append a strategy at the end of the strategy queue. |
||
133 | * |
||
134 | * @param string $strategy Fully qualified class name to a DiscoveryStrategy |
||
135 | */ |
||
136 | public static function appendStrategy($strategy) |
||
141 | |||
142 | /** |
||
143 | * Prepend a strategy at the beginning of the strategy queue. |
||
144 | * |
||
145 | * @param string $strategy Fully qualified class name to a DiscoveryStrategy |
||
146 | */ |
||
147 | public static function prependStrategy($strategy) |
||
152 | |||
153 | /** |
||
154 | * Clear the cache. |
||
155 | */ |
||
156 | public static function clearCache() |
||
160 | |||
161 | /** |
||
162 | * Evaulates conditions to boolean. |
||
163 | * |
||
164 | * @param mixed $condition |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | protected static function evaluateCondition($condition) |
||
190 | |||
191 | /** |
||
192 | * Get an instance of the $class. |
||
193 | * |
||
194 | * @param string|\Closure $class A FQCN of a class or a closure that instantiate the class. |
||
195 | * |
||
196 | * @return object |
||
197 | * |
||
198 | * @throws ClassInstantiationFailedException |
||
199 | */ |
||
200 | protected static function instantiateClass($class) |
||
216 | } |
||
217 |