@@ -30,49 +30,49 @@ discard block |
||
30 | 30 | const REPLACE_ONLY = 'replace-only'; |
31 | 31 | const MERGE_ONLY = 'merge-only'; |
32 | 32 | |
33 | - /** |
|
34 | - * Check whether the Findable can handle an individual criterion. |
|
35 | - * |
|
36 | - * @since 0.1.0 |
|
37 | - * |
|
38 | - * @param mixed $criterion Criterion to check. |
|
39 | - * |
|
40 | - * @return bool Whether the Findable can handle the criterion. |
|
41 | - */ |
|
42 | - public function canHandle($criterion): bool; |
|
33 | + /** |
|
34 | + * Check whether the Findable can handle an individual criterion. |
|
35 | + * |
|
36 | + * @since 0.1.0 |
|
37 | + * |
|
38 | + * @param mixed $criterion Criterion to check. |
|
39 | + * |
|
40 | + * @return bool Whether the Findable can handle the criterion. |
|
41 | + */ |
|
42 | + public function canHandle($criterion): bool; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Render the view. |
|
46 | - * |
|
47 | - * @since 0.1.0 |
|
48 | - * |
|
49 | - * @param array $context Optional. The context in which to render the view. |
|
50 | - * |
|
51 | - * @return string Rendered HTML. |
|
52 | - */ |
|
53 | - public function render(array $context = []): string; |
|
44 | + /** |
|
45 | + * Render the view. |
|
46 | + * |
|
47 | + * @since 0.1.0 |
|
48 | + * |
|
49 | + * @param array $context Optional. The context in which to render the view. |
|
50 | + * |
|
51 | + * @return string Rendered HTML. |
|
52 | + */ |
|
53 | + public function render(array $context = []): string; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Render a partial view (or section) for a given URI. |
|
57 | - * |
|
58 | - * @since 0.2.0 |
|
59 | - * |
|
60 | - * @param string $view View identifier to create a view for. |
|
61 | - * @param array $context Optional. The context in which to render the view. |
|
62 | - * @param string|null $type Type of view to create. |
|
63 | - * |
|
64 | - * @return string Rendered HTML content. |
|
65 | - */ |
|
66 | - public function section(string $view, array $context = [], $type = null): string; |
|
55 | + /** |
|
56 | + * Render a partial view (or section) for a given URI. |
|
57 | + * |
|
58 | + * @since 0.2.0 |
|
59 | + * |
|
60 | + * @param string $view View identifier to create a view for. |
|
61 | + * @param array $context Optional. The context in which to render the view. |
|
62 | + * @param string|null $type Type of view to create. |
|
63 | + * |
|
64 | + * @return string Rendered HTML content. |
|
65 | + */ |
|
66 | + public function section(string $view, array $context = [], $type = null): string; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get the entire array of contextual data. |
|
70 | - * |
|
71 | - * @since 0.4.0 |
|
72 | - * |
|
73 | - * @return array Array of contextual data. |
|
74 | - */ |
|
75 | - public function getContext(): array; |
|
68 | + /** |
|
69 | + * Get the entire array of contextual data. |
|
70 | + * |
|
71 | + * @since 0.4.0 |
|
72 | + * |
|
73 | + * @return array Array of contextual data. |
|
74 | + */ |
|
75 | + public function getContext(): array; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Add information to the context. |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function addToContext( string $key, $value, string $behavior ): View; |
86 | 86 | |
87 | - /** |
|
88 | - * Associate a view builder with this view. |
|
89 | - * |
|
90 | - * @since 0.2.0 |
|
91 | - * |
|
92 | - * @param ViewBuilder $builder |
|
93 | - * |
|
94 | - * @return View |
|
95 | - */ |
|
96 | - public function setBuilder(ViewBuilder $builder): View; |
|
87 | + /** |
|
88 | + * Associate a view builder with this view. |
|
89 | + * |
|
90 | + * @since 0.2.0 |
|
91 | + * |
|
92 | + * @param ViewBuilder $builder |
|
93 | + * |
|
94 | + * @return View |
|
95 | + */ |
|
96 | + public function setBuilder(ViewBuilder $builder): View; |
|
97 | 97 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | * @param string $behavior Behavior to use for adapting the context. |
83 | 83 | * @return View |
84 | 84 | */ |
85 | - public function addToContext( string $key, $value, string $behavior ): View; |
|
85 | + public function addToContext(string $key, $value, string $behavior): View; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Associate a view builder with this view. |
@@ -31,233 +31,233 @@ |
||
31 | 31 | abstract class AbstractView implements View |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * URI of the view. |
|
36 | - * |
|
37 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
38 | - * |
|
39 | - * @since 0.1.0 |
|
40 | - * |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $_uri_; |
|
34 | + /** |
|
35 | + * URI of the view. |
|
36 | + * |
|
37 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
38 | + * |
|
39 | + * @since 0.1.0 |
|
40 | + * |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $_uri_; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Engine to use for the view. |
|
47 | - * |
|
48 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
49 | - * |
|
50 | - * @since 0.1.0 |
|
51 | - * |
|
52 | - * @var Engine |
|
53 | - */ |
|
54 | - protected $_engine_; |
|
45 | + /** |
|
46 | + * Engine to use for the view. |
|
47 | + * |
|
48 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
49 | + * |
|
50 | + * @since 0.1.0 |
|
51 | + * |
|
52 | + * @var Engine |
|
53 | + */ |
|
54 | + protected $_engine_; |
|
55 | 55 | |
56 | - /** |
|
57 | - * ViewBuilder instance. |
|
58 | - * |
|
59 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
60 | - * |
|
61 | - * @since 0.2.0 |
|
62 | - * |
|
63 | - * @var ViewBuilder |
|
64 | - */ |
|
65 | - protected $_builder_; |
|
56 | + /** |
|
57 | + * ViewBuilder instance. |
|
58 | + * |
|
59 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
60 | + * |
|
61 | + * @since 0.2.0 |
|
62 | + * |
|
63 | + * @var ViewBuilder |
|
64 | + */ |
|
65 | + protected $_builder_; |
|
66 | 66 | |
67 | - /** |
|
68 | - * The context with which the view will be rendered. |
|
69 | - * |
|
70 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
71 | - * |
|
72 | - * @since 0.4.0 |
|
73 | - * |
|
74 | - * @var array |
|
75 | - */ |
|
76 | - protected $_context_; |
|
67 | + /** |
|
68 | + * The context with which the view will be rendered. |
|
69 | + * |
|
70 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
71 | + * |
|
72 | + * @since 0.4.0 |
|
73 | + * |
|
74 | + * @var array |
|
75 | + */ |
|
76 | + protected $_context_; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Instantiate an AbstractView object. |
|
80 | - * |
|
81 | - * @since 0.1.0 |
|
82 | - * |
|
83 | - * @param string $uri URI for the view. |
|
84 | - * @param Engine $engine Engine to use for the view. |
|
85 | - * @param ViewBuilder $viewBuilder View builder instance to use. |
|
86 | - * @param array $context Initial context to use. |
|
87 | - */ |
|
88 | - public function __construct(string $uri, Engine $engine, ViewBuilder $viewBuilder = null, array $context = []) |
|
89 | - { |
|
90 | - $this->_uri_ = $uri; |
|
91 | - $this->_engine_ = $engine; |
|
92 | - $this->_builder_ = $viewBuilder ?? Views::getViewBuilder(); |
|
93 | - $this->_context_ = $context; |
|
94 | - } |
|
78 | + /** |
|
79 | + * Instantiate an AbstractView object. |
|
80 | + * |
|
81 | + * @since 0.1.0 |
|
82 | + * |
|
83 | + * @param string $uri URI for the view. |
|
84 | + * @param Engine $engine Engine to use for the view. |
|
85 | + * @param ViewBuilder $viewBuilder View builder instance to use. |
|
86 | + * @param array $context Initial context to use. |
|
87 | + */ |
|
88 | + public function __construct(string $uri, Engine $engine, ViewBuilder $viewBuilder = null, array $context = []) |
|
89 | + { |
|
90 | + $this->_uri_ = $uri; |
|
91 | + $this->_engine_ = $engine; |
|
92 | + $this->_builder_ = $viewBuilder ?? Views::getViewBuilder(); |
|
93 | + $this->_context_ = $context; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Render the view. |
|
98 | - * |
|
99 | - * @since 0.1.0 |
|
100 | - * |
|
101 | - * @param array $context Optional. The context in which to render the view. |
|
102 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
103 | - * |
|
104 | - * @return string Rendered HTML. |
|
105 | - * @throws FailedToProcessConfigException If the Config could not be processed. |
|
106 | - */ |
|
107 | - public function render(array $context = [], bool $echo = false): string |
|
108 | - { |
|
109 | - $this->assimilateContext($context); |
|
96 | + /** |
|
97 | + * Render the view. |
|
98 | + * |
|
99 | + * @since 0.1.0 |
|
100 | + * |
|
101 | + * @param array $context Optional. The context in which to render the view. |
|
102 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
103 | + * |
|
104 | + * @return string Rendered HTML. |
|
105 | + * @throws FailedToProcessConfigException If the Config could not be processed. |
|
106 | + */ |
|
107 | + public function render(array $context = [], bool $echo = false): string |
|
108 | + { |
|
109 | + $this->assimilateContext($context); |
|
110 | 110 | |
111 | - $closure = Closure::bind( |
|
112 | - $this->_engine_->getRenderCallback($this->_uri_, $context), |
|
113 | - $this, |
|
114 | - static::class |
|
115 | - ); |
|
111 | + $closure = Closure::bind( |
|
112 | + $this->_engine_->getRenderCallback($this->_uri_, $context), |
|
113 | + $this, |
|
114 | + static::class |
|
115 | + ); |
|
116 | 116 | |
117 | - $output = $closure(); |
|
117 | + $output = $closure(); |
|
118 | 118 | |
119 | - if ($echo) { |
|
120 | - echo $output; |
|
121 | - } |
|
119 | + if ($echo) { |
|
120 | + echo $output; |
|
121 | + } |
|
122 | 122 | |
123 | - return $output; |
|
124 | - } |
|
123 | + return $output; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Render a partial view (or section) for a given URI. |
|
128 | - * |
|
129 | - * @since 0.2.0 |
|
130 | - * |
|
131 | - * @param string $view View identifier to create a view for. |
|
132 | - * @param array $context Optional. The context in which to render the view. |
|
133 | - * @param string|null $type Type of view to create. |
|
134 | - * |
|
135 | - * @return string Rendered HTML content. |
|
136 | - * @throws FailedToProcessConfigException If the Config could not be processed. |
|
137 | - * @throws FailedToInstantiateView If the View could not be instantiated. |
|
138 | - */ |
|
139 | - public function section(string $view, array $context = null, $type = null): string |
|
140 | - { |
|
141 | - if (null === $context) { |
|
142 | - $context = $this->_context_; |
|
143 | - } |
|
126 | + /** |
|
127 | + * Render a partial view (or section) for a given URI. |
|
128 | + * |
|
129 | + * @since 0.2.0 |
|
130 | + * |
|
131 | + * @param string $view View identifier to create a view for. |
|
132 | + * @param array $context Optional. The context in which to render the view. |
|
133 | + * @param string|null $type Type of view to create. |
|
134 | + * |
|
135 | + * @return string Rendered HTML content. |
|
136 | + * @throws FailedToProcessConfigException If the Config could not be processed. |
|
137 | + * @throws FailedToInstantiateView If the View could not be instantiated. |
|
138 | + */ |
|
139 | + public function section(string $view, array $context = null, $type = null): string |
|
140 | + { |
|
141 | + if (null === $context) { |
|
142 | + $context = $this->_context_; |
|
143 | + } |
|
144 | 144 | |
145 | - $viewObject = $this->_builder_->create($view, $type); |
|
145 | + $viewObject = $this->_builder_->create($view, $type); |
|
146 | 146 | |
147 | - return $viewObject->render($context); |
|
148 | - } |
|
147 | + return $viewObject->render($context); |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Get the entire array of contextual data. |
|
152 | - * |
|
153 | - * @since 0.4.0 |
|
154 | - * |
|
155 | - * @return array Array of contextual data. |
|
156 | - */ |
|
157 | - public function getContext(): array |
|
158 | - { |
|
159 | - return $this->_context_; |
|
160 | - } |
|
150 | + /** |
|
151 | + * Get the entire array of contextual data. |
|
152 | + * |
|
153 | + * @since 0.4.0 |
|
154 | + * |
|
155 | + * @return array Array of contextual data. |
|
156 | + */ |
|
157 | + public function getContext(): array |
|
158 | + { |
|
159 | + return $this->_context_; |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * Add information to the context. |
|
164 | - * |
|
165 | - * @param string $key Context key to add. |
|
166 | - * @param mixed $value Value to add under the given key. |
|
167 | - * @param string $behavior Behavior to use for adapting the context. |
|
168 | - * @return View |
|
169 | - */ |
|
170 | - public function addToContext( string $key, $value, string $behavior ): View |
|
171 | - { |
|
172 | - switch ($behavior) { |
|
173 | - case View::REPLACE: |
|
174 | - $this->_context_[$key] = $value; |
|
175 | - return $this; |
|
176 | - case View::MERGE: |
|
177 | - if(array_key_exists($key, $this->_context_)) { |
|
178 | - $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
179 | - return $this; |
|
180 | - } |
|
181 | - $this->_context_[$key] = $value; |
|
182 | - return $this; |
|
183 | - case View::ADD_ONLY: |
|
184 | - if (array_key_exists($key, $this->_context_)) { |
|
185 | - return $this; |
|
186 | - } |
|
187 | - $this->_context_[$key] = $value; |
|
188 | - return $this; |
|
189 | - case View::REPLACE_ONLY: |
|
190 | - if (! array_key_exists($key, $this->_context_)) { |
|
191 | - return $this; |
|
192 | - } |
|
193 | - $this->_context_[$key] = $value; |
|
194 | - return $this; |
|
195 | - case View::MERGE_ONLY: |
|
196 | - if (! array_key_exists($key, $this->_context_)) { |
|
197 | - return $this; |
|
198 | - } |
|
199 | - $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
200 | - return $this; |
|
201 | - default: |
|
202 | - throw new InvalidContextAddingBehavior( |
|
203 | - sprintf( |
|
204 | - _('Invalid behavior "%s" for adding to the context of view "%s".'), |
|
205 | - $key, |
|
206 | - $this->_uri_ |
|
207 | - ) |
|
208 | - ); |
|
209 | - } |
|
210 | - } |
|
162 | + /** |
|
163 | + * Add information to the context. |
|
164 | + * |
|
165 | + * @param string $key Context key to add. |
|
166 | + * @param mixed $value Value to add under the given key. |
|
167 | + * @param string $behavior Behavior to use for adapting the context. |
|
168 | + * @return View |
|
169 | + */ |
|
170 | + public function addToContext( string $key, $value, string $behavior ): View |
|
171 | + { |
|
172 | + switch ($behavior) { |
|
173 | + case View::REPLACE: |
|
174 | + $this->_context_[$key] = $value; |
|
175 | + return $this; |
|
176 | + case View::MERGE: |
|
177 | + if(array_key_exists($key, $this->_context_)) { |
|
178 | + $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
179 | + return $this; |
|
180 | + } |
|
181 | + $this->_context_[$key] = $value; |
|
182 | + return $this; |
|
183 | + case View::ADD_ONLY: |
|
184 | + if (array_key_exists($key, $this->_context_)) { |
|
185 | + return $this; |
|
186 | + } |
|
187 | + $this->_context_[$key] = $value; |
|
188 | + return $this; |
|
189 | + case View::REPLACE_ONLY: |
|
190 | + if (! array_key_exists($key, $this->_context_)) { |
|
191 | + return $this; |
|
192 | + } |
|
193 | + $this->_context_[$key] = $value; |
|
194 | + return $this; |
|
195 | + case View::MERGE_ONLY: |
|
196 | + if (! array_key_exists($key, $this->_context_)) { |
|
197 | + return $this; |
|
198 | + } |
|
199 | + $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
200 | + return $this; |
|
201 | + default: |
|
202 | + throw new InvalidContextAddingBehavior( |
|
203 | + sprintf( |
|
204 | + _('Invalid behavior "%s" for adding to the context of view "%s".'), |
|
205 | + $key, |
|
206 | + $this->_uri_ |
|
207 | + ) |
|
208 | + ); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * Associate a view builder with this view. |
|
214 | - * |
|
215 | - * @since 0.2.0 |
|
216 | - * |
|
217 | - * @param ViewBuilder $builder |
|
218 | - * |
|
219 | - * @return View |
|
220 | - */ |
|
221 | - public function setBuilder(ViewBuilder $builder): View |
|
222 | - { |
|
223 | - $this->_builder_ = $builder; |
|
212 | + /** |
|
213 | + * Associate a view builder with this view. |
|
214 | + * |
|
215 | + * @since 0.2.0 |
|
216 | + * |
|
217 | + * @param ViewBuilder $builder |
|
218 | + * |
|
219 | + * @return View |
|
220 | + */ |
|
221 | + public function setBuilder(ViewBuilder $builder): View |
|
222 | + { |
|
223 | + $this->_builder_ = $builder; |
|
224 | 224 | |
225 | - return $this; |
|
226 | - } |
|
225 | + return $this; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * Assimilate the context to make it available as properties. |
|
230 | - * |
|
231 | - * @since 0.2.0 |
|
232 | - * |
|
233 | - * @param array $context Context to assimilate. |
|
234 | - */ |
|
235 | - protected function assimilateContext(array $context = []) |
|
236 | - { |
|
237 | - $this->_context_ = $context; |
|
238 | - foreach ($context as $key => $value) { |
|
239 | - $this->$key = $value; |
|
240 | - } |
|
241 | - } |
|
228 | + /** |
|
229 | + * Assimilate the context to make it available as properties. |
|
230 | + * |
|
231 | + * @since 0.2.0 |
|
232 | + * |
|
233 | + * @param array $context Context to assimilate. |
|
234 | + */ |
|
235 | + protected function assimilateContext(array $context = []) |
|
236 | + { |
|
237 | + $this->_context_ = $context; |
|
238 | + foreach ($context as $key => $value) { |
|
239 | + $this->$key = $value; |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Turn invokable objects as properties into methods of the view. |
|
245 | - * |
|
246 | - * @param string $method Method that was called on the view. |
|
247 | - * @param array $arguments Array of arguments that were used. |
|
248 | - * @return mixed Return value of the invokable object. |
|
249 | - */ |
|
250 | - public function __call($method, $arguments) { |
|
251 | - if ( ! property_exists($this, $method) |
|
252 | - || ! is_callable($this->$method)) { |
|
253 | - trigger_error( |
|
254 | - "Call to undefined method {$method} on a view.", |
|
255 | - E_USER_ERROR |
|
256 | - ); |
|
257 | - } |
|
243 | + /** |
|
244 | + * Turn invokable objects as properties into methods of the view. |
|
245 | + * |
|
246 | + * @param string $method Method that was called on the view. |
|
247 | + * @param array $arguments Array of arguments that were used. |
|
248 | + * @return mixed Return value of the invokable object. |
|
249 | + */ |
|
250 | + public function __call($method, $arguments) { |
|
251 | + if ( ! property_exists($this, $method) |
|
252 | + || ! is_callable($this->$method)) { |
|
253 | + trigger_error( |
|
254 | + "Call to undefined method {$method} on a view.", |
|
255 | + E_USER_ERROR |
|
256 | + ); |
|
257 | + } |
|
258 | 258 | |
259 | - $callable = $this->$method; |
|
259 | + $callable = $this->$method; |
|
260 | 260 | |
261 | - return $callable(...$arguments); |
|
262 | - } |
|
261 | + return $callable(...$arguments); |
|
262 | + } |
|
263 | 263 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | * @param string $behavior Behavior to use for adapting the context. |
168 | 168 | * @return View |
169 | 169 | */ |
170 | - public function addToContext( string $key, $value, string $behavior ): View |
|
170 | + public function addToContext(string $key, $value, string $behavior): View |
|
171 | 171 | { |
172 | 172 | switch ($behavior) { |
173 | 173 | case View::REPLACE: |
174 | 174 | $this->_context_[$key] = $value; |
175 | 175 | return $this; |
176 | 176 | case View::MERGE: |
177 | - if(array_key_exists($key, $this->_context_)) { |
|
177 | + if (array_key_exists($key, $this->_context_)) { |
|
178 | 178 | $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
179 | 179 | return $this; |
180 | 180 | } |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $this->_context_[$key] = $value; |
188 | 188 | return $this; |
189 | 189 | case View::REPLACE_ONLY: |
190 | - if (! array_key_exists($key, $this->_context_)) { |
|
190 | + if ( ! array_key_exists($key, $this->_context_)) { |
|
191 | 191 | return $this; |
192 | 192 | } |
193 | 193 | $this->_context_[$key] = $value; |
194 | 194 | return $this; |
195 | 195 | case View::MERGE_ONLY: |
196 | - if (! array_key_exists($key, $this->_context_)) { |
|
196 | + if ( ! array_key_exists($key, $this->_context_)) { |
|
197 | 197 | return $this; |
198 | 198 | } |
199 | 199 | $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
@@ -26,86 +26,86 @@ |
||
26 | 26 | class NullView implements View, NullFindable |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * Check whether the Findable can handle an individual criterion. |
|
31 | - * |
|
32 | - * @since 0.1.0 |
|
33 | - * |
|
34 | - * @param mixed $criterion Criterion to check. |
|
35 | - * |
|
36 | - * @return bool Whether the Findable can handle the criterion. |
|
37 | - */ |
|
38 | - public function canHandle($criterion): bool |
|
39 | - { |
|
40 | - return true; |
|
41 | - } |
|
29 | + /** |
|
30 | + * Check whether the Findable can handle an individual criterion. |
|
31 | + * |
|
32 | + * @since 0.1.0 |
|
33 | + * |
|
34 | + * @param mixed $criterion Criterion to check. |
|
35 | + * |
|
36 | + * @return bool Whether the Findable can handle the criterion. |
|
37 | + */ |
|
38 | + public function canHandle($criterion): bool |
|
39 | + { |
|
40 | + return true; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Render the view. |
|
45 | - * |
|
46 | - * @since 0.1.0 |
|
47 | - * |
|
48 | - * @param array $context Optional. The context in which to render the view. |
|
49 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
50 | - * |
|
51 | - * @return string Rendered HTML. |
|
52 | - */ |
|
53 | - public function render(array $context = [], bool $echo = false): string |
|
54 | - { |
|
55 | - return ''; |
|
56 | - } |
|
43 | + /** |
|
44 | + * Render the view. |
|
45 | + * |
|
46 | + * @since 0.1.0 |
|
47 | + * |
|
48 | + * @param array $context Optional. The context in which to render the view. |
|
49 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
50 | + * |
|
51 | + * @return string Rendered HTML. |
|
52 | + */ |
|
53 | + public function render(array $context = [], bool $echo = false): string |
|
54 | + { |
|
55 | + return ''; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Render a partial view (or section) for a given URI. |
|
60 | - * |
|
61 | - * @since 0.2.0 |
|
62 | - * |
|
63 | - * @param string $view View identifier to create a view for. |
|
64 | - * @param array $context Optional. The context in which to render the view. |
|
65 | - * @param string|null $type Type of view to create. |
|
66 | - * |
|
67 | - * @return string Rendered HTML content. |
|
68 | - */ |
|
69 | - public function section(string $view, array $context = [], $type = null): string |
|
70 | - { |
|
71 | - return ''; |
|
72 | - } |
|
58 | + /** |
|
59 | + * Render a partial view (or section) for a given URI. |
|
60 | + * |
|
61 | + * @since 0.2.0 |
|
62 | + * |
|
63 | + * @param string $view View identifier to create a view for. |
|
64 | + * @param array $context Optional. The context in which to render the view. |
|
65 | + * @param string|null $type Type of view to create. |
|
66 | + * |
|
67 | + * @return string Rendered HTML content. |
|
68 | + */ |
|
69 | + public function section(string $view, array $context = [], $type = null): string |
|
70 | + { |
|
71 | + return ''; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Get the entire array of contextual data. |
|
76 | - * |
|
77 | - * @since 0.4.0 |
|
78 | - * |
|
79 | - * @return array Array of contextual data. |
|
80 | - */ |
|
81 | - public function getContext(): array |
|
82 | - { |
|
83 | - return []; |
|
84 | - } |
|
74 | + /** |
|
75 | + * Get the entire array of contextual data. |
|
76 | + * |
|
77 | + * @since 0.4.0 |
|
78 | + * |
|
79 | + * @return array Array of contextual data. |
|
80 | + */ |
|
81 | + public function getContext(): array |
|
82 | + { |
|
83 | + return []; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Add information to the context. |
|
88 | - * |
|
89 | - * @param string $key Context key to add. |
|
90 | - * @param mixed $value Value to add under the given key. |
|
91 | - * @param string $behavior Behavior to use for adapting the context. |
|
92 | - * @return View |
|
93 | - */ |
|
94 | - public function addToContext( string $key, $value, string $behavior ): View { |
|
95 | - return $this; |
|
96 | - } |
|
86 | + /** |
|
87 | + * Add information to the context. |
|
88 | + * |
|
89 | + * @param string $key Context key to add. |
|
90 | + * @param mixed $value Value to add under the given key. |
|
91 | + * @param string $behavior Behavior to use for adapting the context. |
|
92 | + * @return View |
|
93 | + */ |
|
94 | + public function addToContext( string $key, $value, string $behavior ): View { |
|
95 | + return $this; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Associate a view builder with this view. |
|
100 | - * |
|
101 | - * @since 0.2.0 |
|
102 | - * |
|
103 | - * @param ViewBuilder $builder |
|
104 | - * |
|
105 | - * @return View |
|
106 | - */ |
|
107 | - public function setBuilder(ViewBuilder $builder): View |
|
108 | - { |
|
109 | - return $this; |
|
110 | - } |
|
98 | + /** |
|
99 | + * Associate a view builder with this view. |
|
100 | + * |
|
101 | + * @since 0.2.0 |
|
102 | + * |
|
103 | + * @param ViewBuilder $builder |
|
104 | + * |
|
105 | + * @return View |
|
106 | + */ |
|
107 | + public function setBuilder(ViewBuilder $builder): View |
|
108 | + { |
|
109 | + return $this; |
|
110 | + } |
|
111 | 111 | } |
@@ -91,7 +91,7 @@ |
||
91 | 91 | * @param string $behavior Behavior to use for adapting the context. |
92 | 92 | * @return View |
93 | 93 | */ |
94 | - public function addToContext( string $key, $value, string $behavior ): View { |
|
94 | + public function addToContext(string $key, $value, string $behavior): View { |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 |