@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @since 0.1.0 |
92 | 92 | * |
93 | 93 | * @param string $view View identifier to create a view for. |
94 | - * @param mixed $type Type of view to create. |
|
94 | + * @param string|null $type Type of view to create. |
|
95 | 95 | * |
96 | 96 | * @return ViewInterface Instance of the requested view. |
97 | 97 | */ |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @since 0.1.0 |
192 | 192 | * |
193 | - * @param array $criteria Criteria to match. |
|
193 | + * @param string[] $criteria Criteria to match. |
|
194 | 194 | * |
195 | 195 | * @return string|false URI of the requested view, or false if not found. |
196 | 196 | */ |
@@ -34,241 +34,241 @@ |
||
34 | 34 | class ViewBuilder |
35 | 35 | { |
36 | 36 | |
37 | - use ConfigTrait; |
|
37 | + use ConfigTrait; |
|
38 | 38 | |
39 | - const ENGINE_FINDER_KEY = 'EngineFinder'; |
|
40 | - const VIEW_FINDER_KEY = 'ViewFinder'; |
|
39 | + const ENGINE_FINDER_KEY = 'EngineFinder'; |
|
40 | + const VIEW_FINDER_KEY = 'ViewFinder'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * ViewFinder instance. |
|
44 | - * |
|
45 | - * @since 0.1.0 |
|
46 | - * |
|
47 | - * @var ViewFinderInterface |
|
48 | - */ |
|
49 | - protected $viewFinder; |
|
42 | + /** |
|
43 | + * ViewFinder instance. |
|
44 | + * |
|
45 | + * @since 0.1.0 |
|
46 | + * |
|
47 | + * @var ViewFinderInterface |
|
48 | + */ |
|
49 | + protected $viewFinder; |
|
50 | 50 | |
51 | - /** |
|
52 | - * EngineFinder instance. |
|
53 | - * |
|
54 | - * @since 0.1.0 |
|
55 | - * |
|
56 | - * @var EngineFinderInterface |
|
57 | - */ |
|
58 | - protected $engineFinder; |
|
51 | + /** |
|
52 | + * EngineFinder instance. |
|
53 | + * |
|
54 | + * @since 0.1.0 |
|
55 | + * |
|
56 | + * @var EngineFinderInterface |
|
57 | + */ |
|
58 | + protected $engineFinder; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Locations to scan for views. |
|
62 | - * |
|
63 | - * @since 0.1.0 |
|
64 | - * |
|
65 | - * @var LocationCollection |
|
66 | - */ |
|
67 | - protected $locations; |
|
60 | + /** |
|
61 | + * Locations to scan for views. |
|
62 | + * |
|
63 | + * @since 0.1.0 |
|
64 | + * |
|
65 | + * @var LocationCollection |
|
66 | + */ |
|
67 | + protected $locations; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Instantiate a ViewBuilder object. |
|
71 | - * |
|
72 | - * @since 0.1.0 |
|
73 | - * |
|
74 | - * @param ConfigInterface $config Configuration settings. |
|
75 | - * @param ViewFinderInterface|null $viewFinder ViewFinder instance. |
|
76 | - * @param EngineFinderInterface|null $engineFinder EngineFinder instance. |
|
77 | - * |
|
78 | - * @throws FailedToProcessConfigException If the config could not be processed. |
|
79 | - */ |
|
80 | - public function __construct( |
|
81 | - ConfigInterface $config, |
|
82 | - ViewFinderInterface $viewFinder = null, |
|
83 | - EngineFinderInterface $engineFinder = null |
|
84 | - ) { |
|
85 | - $this->processConfig($config); |
|
86 | - $this->viewFinder = $viewFinder; |
|
87 | - $this->engineFinder = $engineFinder; |
|
88 | - $this->locations = new LocationCollection(); |
|
89 | - } |
|
69 | + /** |
|
70 | + * Instantiate a ViewBuilder object. |
|
71 | + * |
|
72 | + * @since 0.1.0 |
|
73 | + * |
|
74 | + * @param ConfigInterface $config Configuration settings. |
|
75 | + * @param ViewFinderInterface|null $viewFinder ViewFinder instance. |
|
76 | + * @param EngineFinderInterface|null $engineFinder EngineFinder instance. |
|
77 | + * |
|
78 | + * @throws FailedToProcessConfigException If the config could not be processed. |
|
79 | + */ |
|
80 | + public function __construct( |
|
81 | + ConfigInterface $config, |
|
82 | + ViewFinderInterface $viewFinder = null, |
|
83 | + EngineFinderInterface $engineFinder = null |
|
84 | + ) { |
|
85 | + $this->processConfig($config); |
|
86 | + $this->viewFinder = $viewFinder; |
|
87 | + $this->engineFinder = $engineFinder; |
|
88 | + $this->locations = new LocationCollection(); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Create a new view for a given URI. |
|
93 | - * |
|
94 | - * @since 0.1.0 |
|
95 | - * |
|
96 | - * @param string $view View identifier to create a view for. |
|
97 | - * @param mixed $type Type of view to create. |
|
98 | - * |
|
99 | - * @return ViewInterface Instance of the requested view. |
|
100 | - */ |
|
101 | - public function create($view, $type = null) |
|
102 | - { |
|
103 | - $uri = $this->scanLocations([$view]); |
|
104 | - $engine = $this->getEngine($uri); |
|
91 | + /** |
|
92 | + * Create a new view for a given URI. |
|
93 | + * |
|
94 | + * @since 0.1.0 |
|
95 | + * |
|
96 | + * @param string $view View identifier to create a view for. |
|
97 | + * @param mixed $type Type of view to create. |
|
98 | + * |
|
99 | + * @return ViewInterface Instance of the requested view. |
|
100 | + */ |
|
101 | + public function create($view, $type = null) |
|
102 | + { |
|
103 | + $uri = $this->scanLocations([$view]); |
|
104 | + $engine = $this->getEngine($uri); |
|
105 | 105 | |
106 | - return $uri |
|
107 | - ? $this->getView($uri, $engine, $type) |
|
108 | - : $this->getViewFinder()->getNullObject(); |
|
109 | - } |
|
106 | + return $uri |
|
107 | + ? $this->getView($uri, $engine, $type) |
|
108 | + : $this->getViewFinder()->getNullObject(); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Get an Engine that can deal with the given URI. |
|
113 | - * |
|
114 | - * @since 0.1.0 |
|
115 | - * |
|
116 | - * @param string|false $uri URI to get an engine for. |
|
117 | - * |
|
118 | - * @return EngineInterface Instance of an engine that can deal with the given URI. |
|
119 | - */ |
|
120 | - public function getEngine($uri) |
|
121 | - { |
|
122 | - return $this->getEngineFinder()->find([$uri]); |
|
123 | - } |
|
111 | + /** |
|
112 | + * Get an Engine that can deal with the given URI. |
|
113 | + * |
|
114 | + * @since 0.1.0 |
|
115 | + * |
|
116 | + * @param string|false $uri URI to get an engine for. |
|
117 | + * |
|
118 | + * @return EngineInterface Instance of an engine that can deal with the given URI. |
|
119 | + */ |
|
120 | + public function getEngine($uri) |
|
121 | + { |
|
122 | + return $this->getEngineFinder()->find([$uri]); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Get a view for a given URI, engine and type. |
|
127 | - * |
|
128 | - * @since 0.1.0 |
|
129 | - * |
|
130 | - * @param string $uri URI to get a view for. |
|
131 | - * @param EngineInterface $engine Engine to use for the view. |
|
132 | - * @param mixed $type Type of view to get. |
|
133 | - * |
|
134 | - * @return ViewInterface View that matches the given requirements. |
|
135 | - */ |
|
136 | - public function getView($uri, EngineInterface $engine, $type = null) |
|
137 | - { |
|
138 | - if (null === $type) { |
|
139 | - return $this->getViewFinder()->find([$uri], $engine); |
|
140 | - } |
|
125 | + /** |
|
126 | + * Get a view for a given URI, engine and type. |
|
127 | + * |
|
128 | + * @since 0.1.0 |
|
129 | + * |
|
130 | + * @param string $uri URI to get a view for. |
|
131 | + * @param EngineInterface $engine Engine to use for the view. |
|
132 | + * @param mixed $type Type of view to get. |
|
133 | + * |
|
134 | + * @return ViewInterface View that matches the given requirements. |
|
135 | + */ |
|
136 | + public function getView($uri, EngineInterface $engine, $type = null) |
|
137 | + { |
|
138 | + if (null === $type) { |
|
139 | + return $this->getViewFinder()->find([$uri], $engine); |
|
140 | + } |
|
141 | 141 | |
142 | - return $this->resolveType($type, $uri, $engine); |
|
143 | - } |
|
142 | + return $this->resolveType($type, $uri, $engine); |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Get the ViewFinder instance. |
|
147 | - * |
|
148 | - * @since 0.1.0 |
|
149 | - * |
|
150 | - * @return ViewFinderInterface Instance of a ViewFinder. |
|
151 | - */ |
|
152 | - public function getViewFinder() |
|
153 | - { |
|
154 | - return $this->getFinder($this->viewFinder, static::VIEW_FINDER_KEY); |
|
155 | - } |
|
145 | + /** |
|
146 | + * Get the ViewFinder instance. |
|
147 | + * |
|
148 | + * @since 0.1.0 |
|
149 | + * |
|
150 | + * @return ViewFinderInterface Instance of a ViewFinder. |
|
151 | + */ |
|
152 | + public function getViewFinder() |
|
153 | + { |
|
154 | + return $this->getFinder($this->viewFinder, static::VIEW_FINDER_KEY); |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Get the EngineFinder instance. |
|
159 | - * |
|
160 | - * @since 0.1.0 |
|
161 | - * |
|
162 | - * @return EngineFinderInterface Instance of a EngineFinder. |
|
163 | - */ |
|
164 | - public function getEngineFinder() |
|
165 | - { |
|
166 | - return $this->getFinder($this->engineFinder, static::ENGINE_FINDER_KEY); |
|
167 | - } |
|
157 | + /** |
|
158 | + * Get the EngineFinder instance. |
|
159 | + * |
|
160 | + * @since 0.1.0 |
|
161 | + * |
|
162 | + * @return EngineFinderInterface Instance of a EngineFinder. |
|
163 | + */ |
|
164 | + public function getEngineFinder() |
|
165 | + { |
|
166 | + return $this->getFinder($this->engineFinder, static::ENGINE_FINDER_KEY); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Add a location to scan with the ViewFinder. |
|
171 | - * |
|
172 | - * @since 0.1.0 |
|
173 | - * |
|
174 | - * @param LocationInterface $location Location to scan with the ViewFinder. |
|
175 | - */ |
|
176 | - public function addLocation(LocationInterface $location) |
|
177 | - { |
|
178 | - $this->locations->add($location); |
|
179 | - } |
|
169 | + /** |
|
170 | + * Add a location to scan with the ViewFinder. |
|
171 | + * |
|
172 | + * @since 0.1.0 |
|
173 | + * |
|
174 | + * @param LocationInterface $location Location to scan with the ViewFinder. |
|
175 | + */ |
|
176 | + public function addLocation(LocationInterface $location) |
|
177 | + { |
|
178 | + $this->locations->add($location); |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Get the collection of locations registered with this ViewBuilder. |
|
183 | - * |
|
184 | - * @since 0.1.3 |
|
185 | - * |
|
186 | - * @return LocationCollection Collection of locations. |
|
187 | - */ |
|
188 | - public function getLocations() |
|
189 | - { |
|
190 | - return $this->locations; |
|
191 | - } |
|
181 | + /** |
|
182 | + * Get the collection of locations registered with this ViewBuilder. |
|
183 | + * |
|
184 | + * @since 0.1.3 |
|
185 | + * |
|
186 | + * @return LocationCollection Collection of locations. |
|
187 | + */ |
|
188 | + public function getLocations() |
|
189 | + { |
|
190 | + return $this->locations; |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Scan Locations for an URI that matches the specified criteria. |
|
195 | - * |
|
196 | - * @since 0.1.0 |
|
197 | - * |
|
198 | - * @param array $criteria Criteria to match. |
|
199 | - * |
|
200 | - * @return string|false URI of the requested view, or false if not found. |
|
201 | - */ |
|
202 | - public function scanLocations(array $criteria) |
|
203 | - { |
|
204 | - $uris = $this->locations->map(function ($location) use ($criteria) { |
|
205 | - /** @var LocationInterface $location */ |
|
206 | - return $location->getURI($criteria); |
|
207 | - })->filter(function ($uri) { |
|
208 | - return false !== $uri; |
|
209 | - }); |
|
193 | + /** |
|
194 | + * Scan Locations for an URI that matches the specified criteria. |
|
195 | + * |
|
196 | + * @since 0.1.0 |
|
197 | + * |
|
198 | + * @param array $criteria Criteria to match. |
|
199 | + * |
|
200 | + * @return string|false URI of the requested view, or false if not found. |
|
201 | + */ |
|
202 | + public function scanLocations(array $criteria) |
|
203 | + { |
|
204 | + $uris = $this->locations->map(function ($location) use ($criteria) { |
|
205 | + /** @var LocationInterface $location */ |
|
206 | + return $location->getURI($criteria); |
|
207 | + })->filter(function ($uri) { |
|
208 | + return false !== $uri; |
|
209 | + }); |
|
210 | 210 | |
211 | - return $uris->count() > 0 ? $uris->first() : false; |
|
212 | - } |
|
211 | + return $uris->count() > 0 ? $uris->first() : false; |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Get a finder instance. |
|
216 | - * |
|
217 | - * @since 0.1.1 |
|
218 | - * |
|
219 | - * @param mixed $property Property to use. |
|
220 | - * @param string $key Configuration key to use. |
|
221 | - * |
|
222 | - * @return FinderInterface The requested finder instance. |
|
223 | - */ |
|
224 | - protected function getFinder(&$property, $key) |
|
225 | - { |
|
226 | - if (null === $property) { |
|
227 | - $engineFinderClass = $this->config->getKey($key, 'ClassName'); |
|
228 | - $property = new $engineFinderClass($this->config->getSubConfig($key)); |
|
229 | - } |
|
214 | + /** |
|
215 | + * Get a finder instance. |
|
216 | + * |
|
217 | + * @since 0.1.1 |
|
218 | + * |
|
219 | + * @param mixed $property Property to use. |
|
220 | + * @param string $key Configuration key to use. |
|
221 | + * |
|
222 | + * @return FinderInterface The requested finder instance. |
|
223 | + */ |
|
224 | + protected function getFinder(&$property, $key) |
|
225 | + { |
|
226 | + if (null === $property) { |
|
227 | + $engineFinderClass = $this->config->getKey($key, 'ClassName'); |
|
228 | + $property = new $engineFinderClass($this->config->getSubConfig($key)); |
|
229 | + } |
|
230 | 230 | |
231 | - return $property; |
|
232 | - } |
|
231 | + return $property; |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * Resolve the view type. |
|
236 | - * |
|
237 | - * @since 0.1.0 |
|
238 | - * |
|
239 | - * @param mixed $type Type of view that was requested. |
|
240 | - * @param string $uri URI to get a view for. |
|
241 | - * @param EngineInterface|null $engine Engine to use for the view. |
|
242 | - * |
|
243 | - * @return ViewInterface Resolved View object. |
|
244 | - * @throws FailedToInstantiateViewException If the view type could not be resolved. |
|
245 | - */ |
|
246 | - protected function resolveType($type, $uri, EngineInterface $engine = null) |
|
247 | - { |
|
248 | - $configKey = [static::VIEW_FINDER_KEY, 'Views', $type]; |
|
234 | + /** |
|
235 | + * Resolve the view type. |
|
236 | + * |
|
237 | + * @since 0.1.0 |
|
238 | + * |
|
239 | + * @param mixed $type Type of view that was requested. |
|
240 | + * @param string $uri URI to get a view for. |
|
241 | + * @param EngineInterface|null $engine Engine to use for the view. |
|
242 | + * |
|
243 | + * @return ViewInterface Resolved View object. |
|
244 | + * @throws FailedToInstantiateViewException If the view type could not be resolved. |
|
245 | + */ |
|
246 | + protected function resolveType($type, $uri, EngineInterface $engine = null) |
|
247 | + { |
|
248 | + $configKey = [static::VIEW_FINDER_KEY, 'Views', $type]; |
|
249 | 249 | |
250 | - if (is_string($type) && $this->config->hasKey($configKey)) { |
|
251 | - $className = $this->config->getKey($configKey); |
|
252 | - $type = new $className($uri, $engine); |
|
253 | - } |
|
250 | + if (is_string($type) && $this->config->hasKey($configKey)) { |
|
251 | + $className = $this->config->getKey($configKey); |
|
252 | + $type = new $className($uri, $engine); |
|
253 | + } |
|
254 | 254 | |
255 | - if (is_string($type)) { |
|
256 | - $type = new $type($uri, $engine); |
|
257 | - } |
|
255 | + if (is_string($type)) { |
|
256 | + $type = new $type($uri, $engine); |
|
257 | + } |
|
258 | 258 | |
259 | - if (is_callable($type)) { |
|
260 | - $type = $type($uri, $engine); |
|
261 | - } |
|
259 | + if (is_callable($type)) { |
|
260 | + $type = $type($uri, $engine); |
|
261 | + } |
|
262 | 262 | |
263 | - if (! $type instanceof ViewInterface) { |
|
264 | - throw new FailedToInstantiateViewException( |
|
265 | - sprintf( |
|
266 | - _('Could not instantiate view "%s".'), |
|
267 | - serialize($type) |
|
268 | - ) |
|
269 | - ); |
|
270 | - } |
|
263 | + if (! $type instanceof ViewInterface) { |
|
264 | + throw new FailedToInstantiateViewException( |
|
265 | + sprintf( |
|
266 | + _('Could not instantiate view "%s".'), |
|
267 | + serialize($type) |
|
268 | + ) |
|
269 | + ); |
|
270 | + } |
|
271 | 271 | |
272 | - return $type; |
|
273 | - } |
|
272 | + return $type; |
|
273 | + } |
|
274 | 274 | } |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function scanLocations(array $criteria) |
203 | 203 | { |
204 | - $uris = $this->locations->map(function ($location) use ($criteria) { |
|
204 | + $uris = $this->locations->map(function($location) use ($criteria) { |
|
205 | 205 | /** @var LocationInterface $location */ |
206 | 206 | return $location->getURI($criteria); |
207 | - })->filter(function ($uri) { |
|
207 | + })->filter(function($uri) { |
|
208 | 208 | return false !== $uri; |
209 | 209 | }); |
210 | 210 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $type = $type($uri, $engine); |
261 | 261 | } |
262 | 262 | |
263 | - if (! $type instanceof ViewInterface) { |
|
263 | + if ( ! $type instanceof ViewInterface) { |
|
264 | 264 | throw new FailedToInstantiateViewException( |
265 | 265 | sprintf( |
266 | 266 | _('Could not instantiate view "%s".'), |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function render(array $context = [], $echo = false) |
38 | 38 | { |
39 | - if (! $echo) { |
|
39 | + if ( ! $echo) { |
|
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 | } |
@@ -25,34 +25,34 @@ |
||
25 | 25 | class NullView implements ViewInterface, NullObject, Findable |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Check whether the Findable can handle an individual criterion. |
|
30 | - * |
|
31 | - * @since 0.1.0 |
|
32 | - * |
|
33 | - * @param mixed $criterion Criterion to check. |
|
34 | - * |
|
35 | - * @return bool Whether the Findable can handle the criterion. |
|
36 | - */ |
|
37 | - public function canHandle($criterion) |
|
38 | - { |
|
39 | - return true; |
|
40 | - } |
|
28 | + /** |
|
29 | + * Check whether the Findable can handle an individual criterion. |
|
30 | + * |
|
31 | + * @since 0.1.0 |
|
32 | + * |
|
33 | + * @param mixed $criterion Criterion to check. |
|
34 | + * |
|
35 | + * @return bool Whether the Findable can handle the criterion. |
|
36 | + */ |
|
37 | + public function canHandle($criterion) |
|
38 | + { |
|
39 | + return true; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Render the view. |
|
44 | - * |
|
45 | - * @since 0.1.0 |
|
46 | - * |
|
47 | - * @param array $context Optional. The context in which to render the view. |
|
48 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
49 | - * |
|
50 | - * @return string|void Rendered HTML or nothing, depending on $echo argument. |
|
51 | - */ |
|
52 | - public function render(array $context = [], $echo = false) |
|
53 | - { |
|
54 | - if (! $echo) { |
|
55 | - return ''; |
|
56 | - } |
|
57 | - } |
|
42 | + /** |
|
43 | + * Render the view. |
|
44 | + * |
|
45 | + * @since 0.1.0 |
|
46 | + * |
|
47 | + * @param array $context Optional. The context in which to render the view. |
|
48 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
49 | + * |
|
50 | + * @return string|void Rendered HTML or nothing, depending on $echo argument. |
|
51 | + */ |
|
52 | + public function render(array $context = [], $echo = false) |
|
53 | + { |
|
54 | + if (! $echo) { |
|
55 | + return ''; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | } |
@@ -25,15 +25,15 @@ |
||
25 | 25 | interface ViewFinderInterface extends FinderInterface |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Find a result based on a specific criteria. |
|
30 | - * |
|
31 | - * @since 0.1.0 |
|
32 | - * |
|
33 | - * @param array $criteria Criteria to search for. |
|
34 | - * @param EngineInterface|null $engine Optional. Engine to use with the view. |
|
35 | - * |
|
36 | - * @return ViewInterface View that was found. |
|
37 | - */ |
|
38 | - public function find(array $criteria, EngineInterface $engine = null); |
|
28 | + /** |
|
29 | + * Find a result based on a specific criteria. |
|
30 | + * |
|
31 | + * @since 0.1.0 |
|
32 | + * |
|
33 | + * @param array $criteria Criteria to search for. |
|
34 | + * @param EngineInterface|null $engine Optional. Engine to use with the view. |
|
35 | + * |
|
36 | + * @return ViewInterface View that was found. |
|
37 | + */ |
|
38 | + public function find(array $criteria, EngineInterface $engine = null); |
|
39 | 39 | } |
@@ -24,39 +24,39 @@ |
||
24 | 24 | class EngineFinder extends AbstractFinder |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * Find a result based on a specific criteria. |
|
29 | - * |
|
30 | - * @since 0.1.0 |
|
31 | - * |
|
32 | - * @param array $criteria Criteria to search for. |
|
33 | - * |
|
34 | - * @return EngineInterface Result of the search. |
|
35 | - */ |
|
36 | - public function find(array $criteria) |
|
37 | - { |
|
38 | - $this->initializeFindables(); |
|
27 | + /** |
|
28 | + * Find a result based on a specific criteria. |
|
29 | + * |
|
30 | + * @since 0.1.0 |
|
31 | + * |
|
32 | + * @param array $criteria Criteria to search for. |
|
33 | + * |
|
34 | + * @return EngineInterface Result of the search. |
|
35 | + */ |
|
36 | + public function find(array $criteria) |
|
37 | + { |
|
38 | + $this->initializeFindables(); |
|
39 | 39 | |
40 | - foreach ($criteria as $entry) { |
|
41 | - foreach ($this->findables as $engine) { |
|
42 | - if ($engine->canHandle($entry)) { |
|
43 | - return $engine; |
|
44 | - } |
|
45 | - } |
|
46 | - } |
|
40 | + foreach ($criteria as $entry) { |
|
41 | + foreach ($this->findables as $engine) { |
|
42 | + if ($engine->canHandle($entry)) { |
|
43 | + return $engine; |
|
44 | + } |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - return $this->getNullObject(); |
|
49 | - } |
|
48 | + return $this->getNullObject(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get the config key for the Findables definitions. |
|
53 | - * |
|
54 | - * @since 0.1.0 |
|
55 | - * |
|
56 | - * @return string Config key use to define the Findables. |
|
57 | - */ |
|
58 | - protected function getFindablesConfigKey() |
|
59 | - { |
|
60 | - return 'Engines'; |
|
61 | - } |
|
51 | + /** |
|
52 | + * Get the config key for the Findables definitions. |
|
53 | + * |
|
54 | + * @since 0.1.0 |
|
55 | + * |
|
56 | + * @return string Config key use to define the Findables. |
|
57 | + */ |
|
58 | + protected function getFindablesConfigKey() |
|
59 | + { |
|
60 | + return 'Engines'; |
|
61 | + } |
|
62 | 62 | } |
@@ -25,42 +25,42 @@ |
||
25 | 25 | class ViewFinder extends AbstractFinder |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Find a result based on a specific criteria. |
|
30 | - * |
|
31 | - * @since 0.1.0 |
|
32 | - * |
|
33 | - * @param array $criteria Criteria to search for. |
|
34 | - * @param EngineInterface|null $engine Optional. Engine to use with the view. |
|
35 | - * |
|
36 | - * @return ViewInterface View that was found. |
|
37 | - */ |
|
38 | - public function find(array $criteria, EngineInterface $engine = null) |
|
39 | - { |
|
40 | - $uri = $criteria[0]; |
|
28 | + /** |
|
29 | + * Find a result based on a specific criteria. |
|
30 | + * |
|
31 | + * @since 0.1.0 |
|
32 | + * |
|
33 | + * @param array $criteria Criteria to search for. |
|
34 | + * @param EngineInterface|null $engine Optional. Engine to use with the view. |
|
35 | + * |
|
36 | + * @return ViewInterface View that was found. |
|
37 | + */ |
|
38 | + public function find(array $criteria, EngineInterface $engine = null) |
|
39 | + { |
|
40 | + $uri = $criteria[0]; |
|
41 | 41 | |
42 | - $this->initializeFindables([$uri, $engine]); |
|
42 | + $this->initializeFindables([$uri, $engine]); |
|
43 | 43 | |
44 | - foreach ($criteria as $entry) { |
|
45 | - foreach ($this->findables as $viewObject) { |
|
46 | - if ($viewObject->canHandle($entry)) { |
|
47 | - return $viewObject; |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
44 | + foreach ($criteria as $entry) { |
|
45 | + foreach ($this->findables as $viewObject) { |
|
46 | + if ($viewObject->canHandle($entry)) { |
|
47 | + return $viewObject; |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - return $this->getNullObject(); |
|
53 | - } |
|
52 | + return $this->getNullObject(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the config key for the Findables definitions. |
|
57 | - * |
|
58 | - * @since 0.1.0 |
|
59 | - * |
|
60 | - * @return string Config key use to define the Findables. |
|
61 | - */ |
|
62 | - protected function getFindablesConfigKey() |
|
63 | - { |
|
64 | - return 'Views'; |
|
65 | - } |
|
55 | + /** |
|
56 | + * Get the config key for the Findables definitions. |
|
57 | + * |
|
58 | + * @since 0.1.0 |
|
59 | + * |
|
60 | + * @return string Config key use to define the Findables. |
|
61 | + */ |
|
62 | + protected function getFindablesConfigKey() |
|
63 | + { |
|
64 | + return 'Views'; |
|
65 | + } |
|
66 | 66 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function initializeFindables($arguments = null) |
152 | 152 | { |
153 | - $this->findables = $this->findables->map(function ($findable) use ($arguments) { |
|
153 | + $this->findables = $this->findables->map(function($findable) use ($arguments) { |
|
154 | 154 | return $this->initializeFindable($findable, $arguments); |
155 | 155 | }); |
156 | 156 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $findable = $this->instantiateFindableFromCallable($findable, $arguments); |
192 | 192 | } |
193 | 193 | |
194 | - if (! $findable instanceof Findable) { |
|
194 | + if ( ! $findable instanceof Findable) { |
|
195 | 195 | throw new FailedToInstantiateFindableException( |
196 | 196 | sprintf( |
197 | 197 | _('Could not instantiate Findable "%s".'), |
@@ -27,209 +27,209 @@ |
||
27 | 27 | abstract class AbstractFinder implements FinderInterface |
28 | 28 | { |
29 | 29 | |
30 | - use ConfigTrait; |
|
31 | - |
|
32 | - /** |
|
33 | - * Findable collection that the Finder can iterate through to find a match. |
|
34 | - * |
|
35 | - * @since 0.1.0 |
|
36 | - * |
|
37 | - * @var FindableCollection |
|
38 | - */ |
|
39 | - protected $findables; |
|
40 | - |
|
41 | - /** |
|
42 | - * NullObject that is returned if the Finder could not find a match. |
|
43 | - * |
|
44 | - * @since 0.1.0 |
|
45 | - * |
|
46 | - * @var NullFindable |
|
47 | - */ |
|
48 | - protected $nullObject; |
|
49 | - |
|
50 | - /** |
|
51 | - * Instantiate an AbstractFinder object. |
|
52 | - * |
|
53 | - * @since 0.1.0 |
|
54 | - * |
|
55 | - * @param ConfigInterface $config Configuration of the AbstractFinder. |
|
56 | - * |
|
57 | - * @throws FailedToProcessConfigException If the config could not be processed. |
|
58 | - */ |
|
59 | - public function __construct(ConfigInterface $config) |
|
60 | - { |
|
61 | - $this->processConfig($config); |
|
62 | - $this->findables = new FindableCollection(); |
|
63 | - $this->registerFindables($this->config); |
|
64 | - $this->registerNullObject($this->config); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Register the Findables defined in the given configuration. |
|
69 | - * |
|
70 | - * @since 0.1.0 |
|
71 | - * |
|
72 | - * @param ConfigInterface $config Configuration to register the Findables from. |
|
73 | - */ |
|
74 | - public function registerFindables(ConfigInterface $config) |
|
75 | - { |
|
76 | - foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) { |
|
77 | - $this->findables->set($findableKey, $findableObject); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Register the NullObject defined in the given configuration. |
|
83 | - * |
|
84 | - * @since 0.1.0 |
|
85 | - * |
|
86 | - * @param ConfigInterface $config Configuration to register the NullObject from. |
|
87 | - */ |
|
88 | - public function registerNullObject(ConfigInterface $config) |
|
89 | - { |
|
90 | - $this->nullObject = $config->getKey($this->getNullObjectConfigKey()); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Get the NullObject. |
|
95 | - * |
|
96 | - * @since 0.1.1 |
|
97 | - * |
|
98 | - * @return NullFindable NullObject for the current Finder. |
|
99 | - */ |
|
100 | - public function getNullObject() |
|
101 | - { |
|
102 | - $this->initializeNullObject(); |
|
103 | - |
|
104 | - return $this->nullObject; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get the config key for the Findables definitions. |
|
109 | - * |
|
110 | - * @since 0.1.0 |
|
111 | - * |
|
112 | - * @return string Config key use to define the Findables. |
|
113 | - */ |
|
114 | - protected function getFindablesConfigKey() |
|
115 | - { |
|
116 | - return 'Findables'; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Get the config key for the NullObject definitions. |
|
121 | - * |
|
122 | - * @since 0.1.0 |
|
123 | - * |
|
124 | - * @return string Config key use to define the NullObject. |
|
125 | - */ |
|
126 | - protected function getNullObjectConfigKey() |
|
127 | - { |
|
128 | - return 'NullObject'; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Initialize the NullObject. |
|
133 | - * |
|
134 | - * @since 0.1.1 |
|
135 | - * |
|
136 | - * @param mixed $arguments Optional. Arguments to use. |
|
137 | - */ |
|
138 | - protected function initializeNullObject($arguments = null) |
|
139 | - { |
|
140 | - $this->nullObject = $this->maybeInstantiateFindable($this->nullObject, $arguments); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Initialize the Findables that can be iterated. |
|
145 | - * |
|
146 | - * @param mixed $arguments Optional. Arguments to use. |
|
147 | - * |
|
148 | - * @since 0.1.0 |
|
149 | - * |
|
150 | - */ |
|
151 | - protected function initializeFindables($arguments = null) |
|
152 | - { |
|
153 | - $this->findables = $this->findables->map(function ($findable) use ($arguments) { |
|
154 | - return $this->initializeFindable($findable, $arguments); |
|
155 | - }); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Initialize a single findable by instantiating class name strings and calling closures. |
|
160 | - * |
|
161 | - * @since 0.1.0 |
|
162 | - * |
|
163 | - * @param mixed $findable Findable to instantiate. |
|
164 | - * @param mixed $arguments Optional. Arguments to use. |
|
165 | - * |
|
166 | - * @return Findable Instantiated findable. |
|
167 | - */ |
|
168 | - protected function initializeFindable($findable, $arguments = null) |
|
169 | - { |
|
170 | - return $this->maybeInstantiateFindable($findable, $arguments); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Maybe instantiate a Findable if it is not yet an object. |
|
175 | - * |
|
176 | - * @since 0.1.1 |
|
177 | - * |
|
178 | - * @param mixed $findable Findable to instantiate. |
|
179 | - * @param mixed $arguments Optional. Arguments to use. |
|
180 | - * |
|
181 | - * @return Findable Instantiated findable. |
|
182 | - * @throws FailedToInstantiateFindableException If the findable could not be instantiated. |
|
183 | - */ |
|
184 | - protected function maybeInstantiateFindable($findable, $arguments = null) |
|
185 | - { |
|
186 | - if (is_string($findable)) { |
|
187 | - $findable = $this->instantiateFindableFromString($findable, $arguments); |
|
188 | - } |
|
189 | - |
|
190 | - if (is_callable($findable)) { |
|
191 | - $findable = $this->instantiateFindableFromCallable($findable, $arguments); |
|
192 | - } |
|
193 | - |
|
194 | - if (! $findable instanceof Findable) { |
|
195 | - throw new FailedToInstantiateFindableException( |
|
196 | - sprintf( |
|
197 | - _('Could not instantiate Findable "%s".'), |
|
198 | - serialize($findable) |
|
199 | - ) |
|
200 | - ); |
|
201 | - } |
|
202 | - |
|
203 | - return $findable; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Instantiate a Findable from a string. |
|
208 | - * |
|
209 | - * @since 0.1.1 |
|
210 | - * |
|
211 | - * @param string $string String to use for instantiation. |
|
212 | - * @param mixed $arguments Optional. Arguments to use for instantiation. |
|
213 | - * |
|
214 | - * @return Findable Instantiated Findable. |
|
215 | - */ |
|
216 | - protected function instantiateFindableFromString($string, $arguments = null) |
|
217 | - { |
|
218 | - return new $string(...$arguments); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Instantiate a Findable from a callable. |
|
223 | - * |
|
224 | - * @since 0.1.1 |
|
225 | - * |
|
226 | - * @param callable $callable Callable to use for instantiation. |
|
227 | - * @param mixed $arguments Optional. Arguments to use for instantiation. |
|
228 | - * |
|
229 | - * @return Findable Instantiated Findable. |
|
230 | - */ |
|
231 | - protected function instantiateFindableFromCallable($callable, $arguments = null) |
|
232 | - { |
|
233 | - return $callable(...$arguments); |
|
234 | - } |
|
30 | + use ConfigTrait; |
|
31 | + |
|
32 | + /** |
|
33 | + * Findable collection that the Finder can iterate through to find a match. |
|
34 | + * |
|
35 | + * @since 0.1.0 |
|
36 | + * |
|
37 | + * @var FindableCollection |
|
38 | + */ |
|
39 | + protected $findables; |
|
40 | + |
|
41 | + /** |
|
42 | + * NullObject that is returned if the Finder could not find a match. |
|
43 | + * |
|
44 | + * @since 0.1.0 |
|
45 | + * |
|
46 | + * @var NullFindable |
|
47 | + */ |
|
48 | + protected $nullObject; |
|
49 | + |
|
50 | + /** |
|
51 | + * Instantiate an AbstractFinder object. |
|
52 | + * |
|
53 | + * @since 0.1.0 |
|
54 | + * |
|
55 | + * @param ConfigInterface $config Configuration of the AbstractFinder. |
|
56 | + * |
|
57 | + * @throws FailedToProcessConfigException If the config could not be processed. |
|
58 | + */ |
|
59 | + public function __construct(ConfigInterface $config) |
|
60 | + { |
|
61 | + $this->processConfig($config); |
|
62 | + $this->findables = new FindableCollection(); |
|
63 | + $this->registerFindables($this->config); |
|
64 | + $this->registerNullObject($this->config); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Register the Findables defined in the given configuration. |
|
69 | + * |
|
70 | + * @since 0.1.0 |
|
71 | + * |
|
72 | + * @param ConfigInterface $config Configuration to register the Findables from. |
|
73 | + */ |
|
74 | + public function registerFindables(ConfigInterface $config) |
|
75 | + { |
|
76 | + foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) { |
|
77 | + $this->findables->set($findableKey, $findableObject); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Register the NullObject defined in the given configuration. |
|
83 | + * |
|
84 | + * @since 0.1.0 |
|
85 | + * |
|
86 | + * @param ConfigInterface $config Configuration to register the NullObject from. |
|
87 | + */ |
|
88 | + public function registerNullObject(ConfigInterface $config) |
|
89 | + { |
|
90 | + $this->nullObject = $config->getKey($this->getNullObjectConfigKey()); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Get the NullObject. |
|
95 | + * |
|
96 | + * @since 0.1.1 |
|
97 | + * |
|
98 | + * @return NullFindable NullObject for the current Finder. |
|
99 | + */ |
|
100 | + public function getNullObject() |
|
101 | + { |
|
102 | + $this->initializeNullObject(); |
|
103 | + |
|
104 | + return $this->nullObject; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get the config key for the Findables definitions. |
|
109 | + * |
|
110 | + * @since 0.1.0 |
|
111 | + * |
|
112 | + * @return string Config key use to define the Findables. |
|
113 | + */ |
|
114 | + protected function getFindablesConfigKey() |
|
115 | + { |
|
116 | + return 'Findables'; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Get the config key for the NullObject definitions. |
|
121 | + * |
|
122 | + * @since 0.1.0 |
|
123 | + * |
|
124 | + * @return string Config key use to define the NullObject. |
|
125 | + */ |
|
126 | + protected function getNullObjectConfigKey() |
|
127 | + { |
|
128 | + return 'NullObject'; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Initialize the NullObject. |
|
133 | + * |
|
134 | + * @since 0.1.1 |
|
135 | + * |
|
136 | + * @param mixed $arguments Optional. Arguments to use. |
|
137 | + */ |
|
138 | + protected function initializeNullObject($arguments = null) |
|
139 | + { |
|
140 | + $this->nullObject = $this->maybeInstantiateFindable($this->nullObject, $arguments); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Initialize the Findables that can be iterated. |
|
145 | + * |
|
146 | + * @param mixed $arguments Optional. Arguments to use. |
|
147 | + * |
|
148 | + * @since 0.1.0 |
|
149 | + * |
|
150 | + */ |
|
151 | + protected function initializeFindables($arguments = null) |
|
152 | + { |
|
153 | + $this->findables = $this->findables->map(function ($findable) use ($arguments) { |
|
154 | + return $this->initializeFindable($findable, $arguments); |
|
155 | + }); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Initialize a single findable by instantiating class name strings and calling closures. |
|
160 | + * |
|
161 | + * @since 0.1.0 |
|
162 | + * |
|
163 | + * @param mixed $findable Findable to instantiate. |
|
164 | + * @param mixed $arguments Optional. Arguments to use. |
|
165 | + * |
|
166 | + * @return Findable Instantiated findable. |
|
167 | + */ |
|
168 | + protected function initializeFindable($findable, $arguments = null) |
|
169 | + { |
|
170 | + return $this->maybeInstantiateFindable($findable, $arguments); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Maybe instantiate a Findable if it is not yet an object. |
|
175 | + * |
|
176 | + * @since 0.1.1 |
|
177 | + * |
|
178 | + * @param mixed $findable Findable to instantiate. |
|
179 | + * @param mixed $arguments Optional. Arguments to use. |
|
180 | + * |
|
181 | + * @return Findable Instantiated findable. |
|
182 | + * @throws FailedToInstantiateFindableException If the findable could not be instantiated. |
|
183 | + */ |
|
184 | + protected function maybeInstantiateFindable($findable, $arguments = null) |
|
185 | + { |
|
186 | + if (is_string($findable)) { |
|
187 | + $findable = $this->instantiateFindableFromString($findable, $arguments); |
|
188 | + } |
|
189 | + |
|
190 | + if (is_callable($findable)) { |
|
191 | + $findable = $this->instantiateFindableFromCallable($findable, $arguments); |
|
192 | + } |
|
193 | + |
|
194 | + if (! $findable instanceof Findable) { |
|
195 | + throw new FailedToInstantiateFindableException( |
|
196 | + sprintf( |
|
197 | + _('Could not instantiate Findable "%s".'), |
|
198 | + serialize($findable) |
|
199 | + ) |
|
200 | + ); |
|
201 | + } |
|
202 | + |
|
203 | + return $findable; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Instantiate a Findable from a string. |
|
208 | + * |
|
209 | + * @since 0.1.1 |
|
210 | + * |
|
211 | + * @param string $string String to use for instantiation. |
|
212 | + * @param mixed $arguments Optional. Arguments to use for instantiation. |
|
213 | + * |
|
214 | + * @return Findable Instantiated Findable. |
|
215 | + */ |
|
216 | + protected function instantiateFindableFromString($string, $arguments = null) |
|
217 | + { |
|
218 | + return new $string(...$arguments); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Instantiate a Findable from a callable. |
|
223 | + * |
|
224 | + * @since 0.1.1 |
|
225 | + * |
|
226 | + * @param callable $callable Callable to use for instantiation. |
|
227 | + * @param mixed $arguments Optional. Arguments to use for instantiation. |
|
228 | + * |
|
229 | + * @return Findable Instantiated Findable. |
|
230 | + */ |
|
231 | + protected function instantiateFindableFromCallable($callable, $arguments = null) |
|
232 | + { |
|
233 | + return $callable(...$arguments); |
|
234 | + } |
|
235 | 235 | } |
@@ -25,48 +25,48 @@ |
||
25 | 25 | class LocationCollection extends ArrayCollection |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Adds a location at the end of the collection if it does not already exist. |
|
30 | - * |
|
31 | - * @param mixed $location The location to add. |
|
32 | - * |
|
33 | - * @return boolean Whether the location was added or not. |
|
34 | - */ |
|
35 | - public function add($location) |
|
36 | - { |
|
37 | - if ($this->hasLocation($location)) { |
|
38 | - return false; |
|
39 | - } |
|
28 | + /** |
|
29 | + * Adds a location at the end of the collection if it does not already exist. |
|
30 | + * |
|
31 | + * @param mixed $location The location to add. |
|
32 | + * |
|
33 | + * @return boolean Whether the location was added or not. |
|
34 | + */ |
|
35 | + public function add($location) |
|
36 | + { |
|
37 | + if ($this->hasLocation($location)) { |
|
38 | + return false; |
|
39 | + } |
|
40 | 40 | |
41 | - return parent::add($location); |
|
42 | - } |
|
41 | + return parent::add($location); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Check whether a given location is already registered. |
|
46 | - * |
|
47 | - * For two locations to be equal, both their path and their extensions must be the same. |
|
48 | - * |
|
49 | - * @since 0.1.1 |
|
50 | - * |
|
51 | - * @param LocationInterface $location Location to check the existence of. |
|
52 | - * |
|
53 | - * @return bool Whether the location is already registered or not. |
|
54 | - * |
|
55 | - * @throws InvalidLocationException If the location is not valid. |
|
56 | - */ |
|
57 | - public function hasLocation($location) |
|
58 | - { |
|
59 | - if (! $location instanceof LocationInterface) { |
|
60 | - throw new InvalidLocationException( |
|
61 | - sprintf( |
|
62 | - _('Invalid location to check existence for: "%s".'), |
|
63 | - serialize($location) |
|
64 | - ) |
|
65 | - ); |
|
66 | - } |
|
44 | + /** |
|
45 | + * Check whether a given location is already registered. |
|
46 | + * |
|
47 | + * For two locations to be equal, both their path and their extensions must be the same. |
|
48 | + * |
|
49 | + * @since 0.1.1 |
|
50 | + * |
|
51 | + * @param LocationInterface $location Location to check the existence of. |
|
52 | + * |
|
53 | + * @return bool Whether the location is already registered or not. |
|
54 | + * |
|
55 | + * @throws InvalidLocationException If the location is not valid. |
|
56 | + */ |
|
57 | + public function hasLocation($location) |
|
58 | + { |
|
59 | + if (! $location instanceof LocationInterface) { |
|
60 | + throw new InvalidLocationException( |
|
61 | + sprintf( |
|
62 | + _('Invalid location to check existence for: "%s".'), |
|
63 | + serialize($location) |
|
64 | + ) |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | - return $this->exists(function ($key, $element) use ($location) { |
|
69 | - return $location == $element; |
|
70 | - }); |
|
71 | - } |
|
68 | + return $this->exists(function ($key, $element) use ($location) { |
|
69 | + return $location == $element; |
|
70 | + }); |
|
71 | + } |
|
72 | 72 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function hasLocation($location) |
58 | 58 | { |
59 | - if (! $location instanceof LocationInterface) { |
|
59 | + if ( ! $location instanceof LocationInterface) { |
|
60 | 60 | throw new InvalidLocationException( |
61 | 61 | sprintf( |
62 | 62 | _('Invalid location to check existence for: "%s".'), |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - return $this->exists(function ($key, $element) use ($location) { |
|
68 | + return $this->exists(function($key, $element) use ($location) { |
|
69 | 69 | return $location == $element; |
70 | 70 | }); |
71 | 71 | } |
@@ -22,25 +22,25 @@ |
||
22 | 22 | interface LocationInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Get the first URI that matches the given criteria. |
|
27 | - * |
|
28 | - * @since 0.1.0 |
|
29 | - * |
|
30 | - * @param array $criteria Criteria to match. |
|
31 | - * |
|
32 | - * @return string|false URI that matches the criteria or false if none found. |
|
33 | - */ |
|
34 | - public function getURI(array $criteria); |
|
25 | + /** |
|
26 | + * Get the first URI that matches the given criteria. |
|
27 | + * |
|
28 | + * @since 0.1.0 |
|
29 | + * |
|
30 | + * @param array $criteria Criteria to match. |
|
31 | + * |
|
32 | + * @return string|false URI that matches the criteria or false if none found. |
|
33 | + */ |
|
34 | + public function getURI(array $criteria); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get all URIs that match the given criteria. |
|
38 | - * |
|
39 | - * @since 0.1.1 |
|
40 | - * |
|
41 | - * @param array $criteria Criteria to match. |
|
42 | - * |
|
43 | - * @return URICollection Collection of URIs that matches the criteria or an empty collection if none found. |
|
44 | - */ |
|
45 | - public function getURIs(array $criteria); |
|
36 | + /** |
|
37 | + * Get all URIs that match the given criteria. |
|
38 | + * |
|
39 | + * @since 0.1.1 |
|
40 | + * |
|
41 | + * @param array $criteria Criteria to match. |
|
42 | + * |
|
43 | + * @return URICollection Collection of URIs that matches the criteria or an empty collection if none found. |
|
44 | + */ |
|
45 | + public function getURIs(array $criteria); |
|
46 | 46 | } |
@@ -25,19 +25,19 @@ |
||
25 | 25 | class URICollection extends ArrayCollection |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Create a new URICollection from a Symfony Finder instance. |
|
30 | - * |
|
31 | - * @since 0.1.3 |
|
32 | - * |
|
33 | - * @param Finder $finder The Finder instance to create the URI collection from. |
|
34 | - * |
|
35 | - * @return static New URICollection instance. |
|
36 | - */ |
|
37 | - public static function fromFinder(Finder $finder) |
|
38 | - { |
|
39 | - $elements = array_keys(iterator_to_array($finder)); |
|
28 | + /** |
|
29 | + * Create a new URICollection from a Symfony Finder instance. |
|
30 | + * |
|
31 | + * @since 0.1.3 |
|
32 | + * |
|
33 | + * @param Finder $finder The Finder instance to create the URI collection from. |
|
34 | + * |
|
35 | + * @return static New URICollection instance. |
|
36 | + */ |
|
37 | + public static function fromFinder(Finder $finder) |
|
38 | + { |
|
39 | + $elements = array_keys(iterator_to_array($finder)); |
|
40 | 40 | |
41 | - return new static($elements); |
|
42 | - } |
|
41 | + return new static($elements); |
|
42 | + } |
|
43 | 43 | } |