1 | <?php |
||
27 | final class ConfigurationFactory |
||
28 | { |
||
29 | /** |
||
30 | * @var Strategy[] All strategies that are used by the ConfigurationFactory. |
||
31 | */ |
||
32 | private $strategies = []; |
||
33 | |||
34 | /** |
||
35 | * A series of callables that take the configuration array as parameter and should return that array or a modified |
||
36 | * version of it. |
||
37 | * |
||
38 | * @var callable[] |
||
39 | */ |
||
40 | private $middlewares = []; |
||
41 | |||
42 | /** |
||
43 | * @var string[] |
||
44 | */ |
||
45 | private $defaultFiles = []; |
||
46 | |||
47 | /** |
||
48 | * Initializes the ConfigurationFactory. |
||
49 | * |
||
50 | * @param Strategy[]|iterable $strategies |
||
51 | * @param array $defaultFiles |
||
52 | */ |
||
53 | 9 | public function __construct(iterable $strategies, array $defaultFiles) |
|
60 | |||
61 | /** |
||
62 | * Adds a middleware callback that allows the consumer to alter the configuration array when it is constructed. |
||
63 | * |
||
64 | * @param callable $middleware |
||
65 | */ |
||
66 | 2 | public function addMiddleware(callable $middleware): void |
|
70 | |||
71 | /** |
||
72 | * Attempts to load a configuration from the default locations for phpDocumentor |
||
73 | * |
||
74 | * @return Configuration |
||
75 | */ |
||
76 | 4 | public function fromDefaultLocations(): Configuration |
|
88 | |||
89 | /** |
||
90 | * Converts the phpDocumentor configuration xml to an array. |
||
91 | * |
||
92 | * @param Uri $uri The location of the file to be loaded. |
||
93 | * |
||
94 | * @return Configuration |
||
95 | * @throws RuntimeException if no matching strategy can be found. |
||
96 | * @throws InvalidConfigPathException if $uri points to an inexistent file |
||
97 | */ |
||
98 | 3 | public function fromUri(Uri $uri): Configuration |
|
117 | |||
118 | /** |
||
119 | * Adds strategies that are used in the ConfigurationFactory. |
||
120 | * |
||
121 | * @param Strategy $strategy |
||
122 | */ |
||
123 | 6 | private function registerStrategy(Strategy $strategy): void |
|
127 | |||
128 | /** |
||
129 | * Applies all middleware callbacks onto the configuration. |
||
130 | * |
||
131 | * @param array $configuration |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 5 | private function applyMiddleware(array $configuration): array |
|
143 | } |
||
144 |