@@ -26,95 +26,95 @@ |
||
26 | 26 | class ViewFinder extends AbstractFinder |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * Find a result based on a specific criteria. |
|
31 | - * |
|
32 | - * @since 0.1.0 |
|
33 | - * |
|
34 | - * @param array $criteria Criteria to search for. |
|
35 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
36 | - * |
|
37 | - * @return ViewInterface View that was found. |
|
38 | - */ |
|
39 | - public function find(array $criteria, EngineInterface $engine = null) |
|
40 | - { |
|
41 | - $uri = $criteria[0]; |
|
29 | + /** |
|
30 | + * Find a result based on a specific criteria. |
|
31 | + * |
|
32 | + * @since 0.1.0 |
|
33 | + * |
|
34 | + * @param array $criteria Criteria to search for. |
|
35 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
36 | + * |
|
37 | + * @return ViewInterface View that was found. |
|
38 | + */ |
|
39 | + public function find(array $criteria, EngineInterface $engine = null) |
|
40 | + { |
|
41 | + $uri = $criteria[0]; |
|
42 | 42 | |
43 | - $this->initializeViews($uri, $engine); |
|
43 | + $this->initializeViews($uri, $engine); |
|
44 | 44 | |
45 | - foreach ($criteria as $entry) { |
|
46 | - foreach ($this->findables as $viewObject) { |
|
47 | - if ($viewObject->canHandle($entry)) { |
|
48 | - return $viewObject; |
|
49 | - } |
|
50 | - } |
|
51 | - } |
|
45 | + foreach ($criteria as $entry) { |
|
46 | + foreach ($this->findables as $viewObject) { |
|
47 | + if ($viewObject->canHandle($entry)) { |
|
48 | + return $viewObject; |
|
49 | + } |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - return $this->nullObject; |
|
54 | - } |
|
53 | + return $this->nullObject; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Initialize the views that can be iterated. |
|
58 | - * |
|
59 | - * @since 0.1.0 |
|
60 | - * |
|
61 | - * @param string $uri URI to use for the view. |
|
62 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
63 | - */ |
|
64 | - protected function initializeViews($uri, EngineInterface $engine = null) |
|
65 | - { |
|
66 | - foreach ($this->findables as &$view) { |
|
67 | - $view = $this->initializeView($view, $uri, $engine); |
|
68 | - } |
|
56 | + /** |
|
57 | + * Initialize the views that can be iterated. |
|
58 | + * |
|
59 | + * @since 0.1.0 |
|
60 | + * |
|
61 | + * @param string $uri URI to use for the view. |
|
62 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
63 | + */ |
|
64 | + protected function initializeViews($uri, EngineInterface $engine = null) |
|
65 | + { |
|
66 | + foreach ($this->findables as &$view) { |
|
67 | + $view = $this->initializeView($view, $uri, $engine); |
|
68 | + } |
|
69 | 69 | |
70 | - if (! is_object($this->nullObject)) { |
|
71 | - $this->nullObject = new $this->nullObject(); |
|
72 | - } |
|
73 | - } |
|
70 | + if (! is_object($this->nullObject)) { |
|
71 | + $this->nullObject = new $this->nullObject(); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Initialize a single view by instantiating class name strings and calling closures. |
|
77 | - * |
|
78 | - * @since 0.1.0 |
|
79 | - * |
|
80 | - * @param mixed $view View to instantiate. |
|
81 | - * @param string $uri URI to use for the view. |
|
82 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
83 | - * |
|
84 | - * @return ViewInterface Instantiated view. |
|
85 | - * @throws FailedToInstantiateViewException If the view could not be instantiated. |
|
86 | - */ |
|
87 | - protected function initializeView($view, $uri, EngineInterface $engine = null) |
|
88 | - { |
|
89 | - if (is_string($view)) { |
|
90 | - $view = new $view($uri, $engine); |
|
91 | - } |
|
75 | + /** |
|
76 | + * Initialize a single view by instantiating class name strings and calling closures. |
|
77 | + * |
|
78 | + * @since 0.1.0 |
|
79 | + * |
|
80 | + * @param mixed $view View to instantiate. |
|
81 | + * @param string $uri URI to use for the view. |
|
82 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
83 | + * |
|
84 | + * @return ViewInterface Instantiated view. |
|
85 | + * @throws FailedToInstantiateViewException If the view could not be instantiated. |
|
86 | + */ |
|
87 | + protected function initializeView($view, $uri, EngineInterface $engine = null) |
|
88 | + { |
|
89 | + if (is_string($view)) { |
|
90 | + $view = new $view($uri, $engine); |
|
91 | + } |
|
92 | 92 | |
93 | - if (is_callable($view)) { |
|
94 | - $view = $view($uri, $engine); |
|
95 | - } |
|
93 | + if (is_callable($view)) { |
|
94 | + $view = $view($uri, $engine); |
|
95 | + } |
|
96 | 96 | |
97 | - if (! $view instanceof ViewInterface) { |
|
98 | - throw new FailedToInstantiateViewException( |
|
99 | - sprintf( |
|
100 | - _('Could not instantiate view "%s".'), |
|
101 | - serialize($view) |
|
102 | - ) |
|
103 | - ); |
|
104 | - } |
|
97 | + if (! $view instanceof ViewInterface) { |
|
98 | + throw new FailedToInstantiateViewException( |
|
99 | + sprintf( |
|
100 | + _('Could not instantiate view "%s".'), |
|
101 | + serialize($view) |
|
102 | + ) |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | |
106 | - return $view; |
|
107 | - } |
|
106 | + return $view; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Get the config key for the Findables definitions. |
|
111 | - * |
|
112 | - * @since 0.1.0 |
|
113 | - * |
|
114 | - * @return string Config key use to define the Findables. |
|
115 | - */ |
|
116 | - protected function getFindablesConfigKey() |
|
117 | - { |
|
118 | - return 'Views'; |
|
119 | - } |
|
109 | + /** |
|
110 | + * Get the config key for the Findables definitions. |
|
111 | + * |
|
112 | + * @since 0.1.0 |
|
113 | + * |
|
114 | + * @return string Config key use to define the Findables. |
|
115 | + */ |
|
116 | + protected function getFindablesConfigKey() |
|
117 | + { |
|
118 | + return 'Views'; |
|
119 | + } |
|
120 | 120 | } |
@@ -25,88 +25,88 @@ |
||
25 | 25 | class EngineFinder 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 | - * |
|
35 | - * @return mixed Result of the search. |
|
36 | - */ |
|
37 | - public function find(array $criteria) |
|
38 | - { |
|
39 | - $this->initializeEngines(); |
|
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 | + * |
|
35 | + * @return mixed Result of the search. |
|
36 | + */ |
|
37 | + public function find(array $criteria) |
|
38 | + { |
|
39 | + $this->initializeEngines(); |
|
40 | 40 | |
41 | - foreach ($criteria as $entry) { |
|
42 | - foreach ($this->findables as $engine) { |
|
43 | - if ($engine->canHandle($entry)) { |
|
44 | - return $engine; |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
41 | + foreach ($criteria as $entry) { |
|
42 | + foreach ($this->findables as $engine) { |
|
43 | + if ($engine->canHandle($entry)) { |
|
44 | + return $engine; |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - return $this->nullObject; |
|
50 | - } |
|
49 | + return $this->nullObject; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Initialize the engines that can be iterated. |
|
54 | - * |
|
55 | - * @since 0.1.0 |
|
56 | - * |
|
57 | - */ |
|
58 | - protected function initializeEngines() |
|
59 | - { |
|
60 | - foreach ($this->findables as &$engine) { |
|
61 | - $engine = $this->initializeEngine($engine); |
|
62 | - } |
|
52 | + /** |
|
53 | + * Initialize the engines that can be iterated. |
|
54 | + * |
|
55 | + * @since 0.1.0 |
|
56 | + * |
|
57 | + */ |
|
58 | + protected function initializeEngines() |
|
59 | + { |
|
60 | + foreach ($this->findables as &$engine) { |
|
61 | + $engine = $this->initializeEngine($engine); |
|
62 | + } |
|
63 | 63 | |
64 | - if (! is_object($this->nullObject)) { |
|
65 | - $this->nullObject = new $this->nullObject(); |
|
66 | - } |
|
67 | - } |
|
64 | + if (! is_object($this->nullObject)) { |
|
65 | + $this->nullObject = new $this->nullObject(); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Initialize a single engine by instantiating class name strings and calling closures. |
|
71 | - * |
|
72 | - * @since 0.1.0 |
|
73 | - * |
|
74 | - * @param mixed $engine Engine to instantiate. |
|
75 | - * |
|
76 | - * @return EngineInterface Instantiated engine. |
|
77 | - * @throws FailedToInstantiateEngineException If the engine could not be instantiated. |
|
78 | - */ |
|
79 | - protected function initializeEngine($engine) |
|
80 | - { |
|
81 | - if (is_string($engine)) { |
|
82 | - $engine = new $engine(); |
|
83 | - } |
|
69 | + /** |
|
70 | + * Initialize a single engine by instantiating class name strings and calling closures. |
|
71 | + * |
|
72 | + * @since 0.1.0 |
|
73 | + * |
|
74 | + * @param mixed $engine Engine to instantiate. |
|
75 | + * |
|
76 | + * @return EngineInterface Instantiated engine. |
|
77 | + * @throws FailedToInstantiateEngineException If the engine could not be instantiated. |
|
78 | + */ |
|
79 | + protected function initializeEngine($engine) |
|
80 | + { |
|
81 | + if (is_string($engine)) { |
|
82 | + $engine = new $engine(); |
|
83 | + } |
|
84 | 84 | |
85 | - if (is_callable($engine)) { |
|
86 | - $engine = $engine(); |
|
87 | - } |
|
85 | + if (is_callable($engine)) { |
|
86 | + $engine = $engine(); |
|
87 | + } |
|
88 | 88 | |
89 | - if (! $engine instanceof EngineInterface) { |
|
90 | - throw new FailedToInstantiateEngineException( |
|
91 | - sprintf( |
|
92 | - _('Could not instantiate engine "%s".'), |
|
93 | - serialize($engine) |
|
94 | - ) |
|
95 | - ); |
|
96 | - } |
|
89 | + if (! $engine instanceof EngineInterface) { |
|
90 | + throw new FailedToInstantiateEngineException( |
|
91 | + sprintf( |
|
92 | + _('Could not instantiate engine "%s".'), |
|
93 | + serialize($engine) |
|
94 | + ) |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | - return $engine; |
|
99 | - } |
|
98 | + return $engine; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get the config key for the Findables definitions. |
|
103 | - * |
|
104 | - * @since 0.1.0 |
|
105 | - * |
|
106 | - * @return string Config key use to define the Findables. |
|
107 | - */ |
|
108 | - protected function getFindablesConfigKey() |
|
109 | - { |
|
110 | - return 'Engines'; |
|
111 | - } |
|
101 | + /** |
|
102 | + * Get the config key for the Findables definitions. |
|
103 | + * |
|
104 | + * @since 0.1.0 |
|
105 | + * |
|
106 | + * @return string Config key use to define the Findables. |
|
107 | + */ |
|
108 | + protected function getFindablesConfigKey() |
|
109 | + { |
|
110 | + return 'Engines'; |
|
111 | + } |
|
112 | 112 | } |