1 | <?php |
||
33 | class ViewBuilder |
||
34 | { |
||
35 | |||
36 | use ConfigTrait; |
||
37 | |||
38 | const ENGINE_FINDER_KEY = 'EngineFinder'; |
||
39 | const VIEW_FINDER_KEY = 'ViewFinder'; |
||
40 | |||
41 | /** |
||
42 | * ViewFinder instance. |
||
43 | * |
||
44 | * @since 0.1.0 |
||
45 | * |
||
46 | * @var ViewFinderInterface |
||
47 | */ |
||
48 | protected $viewFinder; |
||
49 | |||
50 | /** |
||
51 | * EngineFinder instance. |
||
52 | * |
||
53 | * @since 0.1.0 |
||
54 | * |
||
55 | * @var EngineFinderInterface |
||
56 | */ |
||
57 | protected $engineFinder; |
||
58 | |||
59 | /** |
||
60 | * Locations to scan for views. |
||
61 | * |
||
62 | * @since 0.1.0 |
||
63 | * |
||
64 | * @var LocationInterface[] |
||
65 | */ |
||
66 | protected $locations; |
||
67 | |||
68 | /** |
||
69 | * Instantiate a ViewBuilder object. |
||
70 | * |
||
71 | * @since 0.1.0 |
||
72 | * |
||
73 | * @param ConfigInterface $config Configuration settings. |
||
74 | * @param ViewFinderInterface|null $viewFinder ViewFinder instance. |
||
75 | * @param EngineFinderInterface|null $engineFinder EngineFinder instance. |
||
76 | * |
||
77 | * @throws FailedToProcessConfigException If the config could not be processed. |
||
78 | */ |
||
79 | 7 | public function __construct( |
|
88 | |||
89 | /** |
||
90 | * Create a new view for a given URI. |
||
91 | * |
||
92 | * @since 0.1.0 |
||
93 | * |
||
94 | * @param string $view View identifier to create a view for. |
||
95 | * @param mixed $type Type of view to create. |
||
96 | * |
||
97 | * @return ViewInterface Instance of the requested view. |
||
98 | */ |
||
99 | 17 | public function create($view, $type = null) |
|
108 | |||
109 | /** |
||
110 | * Get an Engine that can deal with the given URI. |
||
111 | * |
||
112 | * @since 0.1.0 |
||
113 | * |
||
114 | * @param string|false $uri URI to get an engine for. |
||
115 | * |
||
116 | * @return EngineInterface Instance of an engine that can deal with the given URI. |
||
117 | */ |
||
118 | 17 | public function getEngine($uri) |
|
122 | |||
123 | /** |
||
124 | * Get a view for a given URI, engine and type. |
||
125 | * |
||
126 | * @since 0.1.0 |
||
127 | * |
||
128 | * @param string $uri URI to get a view for. |
||
129 | * @param EngineInterface $engine Engine to use for the view. |
||
130 | * @param mixed $type Type of view to get. |
||
131 | * |
||
132 | * @return ViewInterface View that matches the given requirements. |
||
133 | */ |
||
134 | 17 | public function getView($uri, EngineInterface $engine, $type = null) |
|
142 | |||
143 | /** |
||
144 | * Get the ViewFinder instance. |
||
145 | * |
||
146 | * @since 0.1.0 |
||
147 | * |
||
148 | * @return ViewFinderInterface Instance of a ViewFinder. |
||
149 | */ |
||
150 | 17 | public function getViewFinder() |
|
154 | |||
155 | /** |
||
156 | * Get the EngineFinder instance. |
||
157 | * |
||
158 | * @since 0.1.0 |
||
159 | * |
||
160 | * @return EngineFinderInterface Instance of a EngineFinder. |
||
161 | */ |
||
162 | 17 | public function getEngineFinder() |
|
166 | |||
167 | /** |
||
168 | * Add a location to scan with the ViewFinder. |
||
169 | * |
||
170 | * @since 0.1.0 |
||
171 | * |
||
172 | * @param LocationInterface $location Location to scan with the ViewFinder. |
||
173 | */ |
||
174 | 17 | public function addLocation(LocationInterface $location) |
|
178 | |||
179 | /** |
||
180 | * Scan Locations for an URI that matches the specified criteria. |
||
181 | * |
||
182 | * @since 0.1.0 |
||
183 | * |
||
184 | * @param array $criteria Criteria to match. |
||
185 | * |
||
186 | * @return string|false URI of the requested view, or false if not found. |
||
187 | */ |
||
188 | 17 | public function scanLocations(array $criteria) |
|
199 | |||
200 | /** |
||
201 | * Get a finder instance. |
||
202 | * |
||
203 | * @since 0.1.1 |
||
204 | * |
||
205 | * @param mixed $property Property to use. |
||
206 | * @param string $key Configuration key to use. |
||
207 | * |
||
208 | * @return FinderInterface The requested finder instance. |
||
209 | */ |
||
210 | 17 | protected function getFinder(&$property, $key) |
|
219 | |||
220 | /** |
||
221 | * Resolve the view type. |
||
222 | * |
||
223 | * @since 0.1.0 |
||
224 | * |
||
225 | * @param mixed $type Type of view that was requested. |
||
226 | * @param string $uri URI to get a view for. |
||
227 | * @param EngineInterface|null $engine Engine to use for the view. |
||
228 | * |
||
229 | * @return ViewInterface Resolved View object. |
||
230 | * @throws FailedToInstantiateViewException If the view type could not be resolved. |
||
231 | */ |
||
232 | protected function resolveType($type, $uri, EngineInterface $engine = null) |
||
258 | } |
||
259 |
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.