1 | <?php |
||
15 | abstract class ClassDiscovery |
||
16 | { |
||
17 | /** |
||
18 | * A list of strategies to find classes. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private static $strategies = [ |
||
23 | Strategy\Puli::class, |
||
24 | Strategy\CommonClassesStrategy::class, |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Discovery cache to make the second time we use discovery faster. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private static $cache = []; |
||
33 | |||
34 | /** |
||
35 | * Finds a class. |
||
36 | * |
||
37 | * @param string $type |
||
38 | * |
||
39 | * @return string |
||
40 | * |
||
41 | * @throws DiscoveryFailedException |
||
42 | */ |
||
43 | protected static function findOneByType($type) |
||
75 | |||
76 | /** |
||
77 | * Get a value from cache. |
||
78 | * |
||
79 | * @param string $type |
||
80 | * |
||
81 | * @return string|null |
||
82 | */ |
||
83 | private static function getFromCache($type) |
||
96 | |||
97 | /** |
||
98 | * Store a value in cache. |
||
99 | * |
||
100 | * @param string $type |
||
101 | * @param string $class |
||
102 | */ |
||
103 | private static function storeInCache($type, $class) |
||
107 | |||
108 | /** |
||
109 | * Set new strategies and clear the cache. |
||
110 | * |
||
111 | * @param array $strategies |
||
112 | */ |
||
113 | public static function setStrategies(array $strategies) |
||
118 | |||
119 | /** |
||
120 | * Clear the cache. |
||
121 | */ |
||
122 | public static function clearCache() |
||
126 | |||
127 | /** |
||
128 | * Evaulates conditions to boolean. |
||
129 | * |
||
130 | * @param mixed $condition |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | protected static function evaluateCondition($condition) |
||
156 | } |
||
157 |