@@ -27,45 +27,45 @@ |
||
27 | 27 | */ |
28 | 28 | trait Extensions |
29 | 29 | { |
30 | - /** |
|
31 | - * The file extension. |
|
32 | - * |
|
33 | - * @var array $extension |
|
34 | - */ |
|
35 | - protected $extension = [ |
|
36 | - 'plaze.php', |
|
37 | - 'php', |
|
38 | - 'html', |
|
39 | - ]; |
|
30 | + /** |
|
31 | + * The file extension. |
|
32 | + * |
|
33 | + * @var array $extension |
|
34 | + */ |
|
35 | + protected $extension = [ |
|
36 | + 'plaze.php', |
|
37 | + 'php', |
|
38 | + 'html', |
|
39 | + ]; |
|
40 | 40 | |
41 | - /** |
|
42 | - * The type to engine bindings. |
|
43 | - * |
|
44 | - * @var array $extensions |
|
45 | - */ |
|
46 | - protected $extensions = [ |
|
47 | - 'plaze.php' => 'plaze', |
|
48 | - 'php' => 'php', |
|
49 | - 'html' => 'file', |
|
50 | - ]; |
|
41 | + /** |
|
42 | + * The type to engine bindings. |
|
43 | + * |
|
44 | + * @var array $extensions |
|
45 | + */ |
|
46 | + protected $extensions = [ |
|
47 | + 'plaze.php' => 'plaze', |
|
48 | + 'php' => 'php', |
|
49 | + 'html' => 'file', |
|
50 | + ]; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the template file extension. |
|
54 | - * |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function getExtensions(): array |
|
58 | - { |
|
59 | - return $this->extension; |
|
60 | - } |
|
52 | + /** |
|
53 | + * Get the template file extension. |
|
54 | + * |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function getExtensions(): array |
|
58 | + { |
|
59 | + return $this->extension; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get type to engine bindings. |
|
64 | - * |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function getKeysToExtensions(): array |
|
68 | - { |
|
69 | - return array_keys($this->extensions); |
|
70 | - } |
|
62 | + /** |
|
63 | + * Get type to engine bindings. |
|
64 | + * |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function getKeysToExtensions(): array |
|
68 | + { |
|
69 | + return array_keys($this->extensions); |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -36,310 +36,310 @@ |
||
36 | 36 | */ |
37 | 37 | class Factory implements FactoryContract |
38 | 38 | { |
39 | - use Extensions, |
|
40 | - Concerns\ManagesStacks, |
|
41 | - Concerns\ManagesLayouts, |
|
42 | - Concerns\ManagesComponents, |
|
43 | - Concerns\ManagesTranslations; |
|
39 | + use Extensions, |
|
40 | + Concerns\ManagesStacks, |
|
41 | + Concerns\ManagesLayouts, |
|
42 | + Concerns\ManagesComponents, |
|
43 | + Concerns\ManagesTranslations; |
|
44 | 44 | |
45 | - /** |
|
46 | - * The IoC container instance. |
|
47 | - * |
|
48 | - * @var \Syscodes\Components\Contracts\Container\Container $container |
|
49 | - */ |
|
50 | - protected $container; |
|
45 | + /** |
|
46 | + * The IoC container instance. |
|
47 | + * |
|
48 | + * @var \Syscodes\Components\Contracts\Container\Container $container |
|
49 | + */ |
|
50 | + protected $container; |
|
51 | 51 | |
52 | - /** |
|
53 | - * The engine implementation. |
|
54 | - * |
|
55 | - * @var \Syscodes\Components\View\Engines\EngineResolver $engines |
|
56 | - */ |
|
57 | - protected $engines; |
|
52 | + /** |
|
53 | + * The engine implementation. |
|
54 | + * |
|
55 | + * @var \Syscodes\Components\View\Engines\EngineResolver $engines |
|
56 | + */ |
|
57 | + protected $engines; |
|
58 | 58 | |
59 | - /** |
|
60 | - * The event dispatcher instance. |
|
61 | - * |
|
62 | - * @var \Syscodes\Components\Contracts\Events\Dispatcher $events |
|
63 | - */ |
|
64 | - protected $events; |
|
59 | + /** |
|
60 | + * The event dispatcher instance. |
|
61 | + * |
|
62 | + * @var \Syscodes\Components\Contracts\Events\Dispatcher $events |
|
63 | + */ |
|
64 | + protected $events; |
|
65 | 65 | |
66 | - /** |
|
67 | - * The view finder implementation. |
|
68 | - * |
|
69 | - * @var \Syscodes\Components\View\FileViewFinder $finder |
|
70 | - */ |
|
71 | - protected $finder; |
|
66 | + /** |
|
67 | + * The view finder implementation. |
|
68 | + * |
|
69 | + * @var \Syscodes\Components\View\FileViewFinder $finder |
|
70 | + */ |
|
71 | + protected $finder; |
|
72 | 72 | |
73 | - /** |
|
74 | - * The number of active rendering operations. |
|
75 | - * |
|
76 | - * @var int $renderCount |
|
77 | - */ |
|
78 | - protected $renderCount = 0; |
|
73 | + /** |
|
74 | + * The number of active rendering operations. |
|
75 | + * |
|
76 | + * @var int $renderCount |
|
77 | + */ |
|
78 | + protected $renderCount = 0; |
|
79 | 79 | |
80 | - /** |
|
81 | - * Array of shared data. |
|
82 | - * |
|
83 | - * @var array $shared |
|
84 | - */ |
|
85 | - protected $shared = []; |
|
80 | + /** |
|
81 | + * Array of shared data. |
|
82 | + * |
|
83 | + * @var array $shared |
|
84 | + */ |
|
85 | + protected $shared = []; |
|
86 | 86 | |
87 | - /** |
|
88 | - * Constructor. Create a new Parser class instance. |
|
89 | - * |
|
90 | - * @param \Syscodes\Components\View\Engines\EngineResolver $engine |
|
91 | - * @param \Syscodes\Components\Contracts\View\ViewFinder $finder |
|
92 | - * @param \Syscodes\Components\Contracts\Events\Dispatcher $events |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function __construct(EngineResolver $engines, ViewFinder $finder, Dispatcher $events) |
|
97 | - { |
|
98 | - $this->finder = $finder; |
|
99 | - $this->engines = $engines; |
|
100 | - $this->events = $events; |
|
87 | + /** |
|
88 | + * Constructor. Create a new Parser class instance. |
|
89 | + * |
|
90 | + * @param \Syscodes\Components\View\Engines\EngineResolver $engine |
|
91 | + * @param \Syscodes\Components\Contracts\View\ViewFinder $finder |
|
92 | + * @param \Syscodes\Components\Contracts\Events\Dispatcher $events |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function __construct(EngineResolver $engines, ViewFinder $finder, Dispatcher $events) |
|
97 | + { |
|
98 | + $this->finder = $finder; |
|
99 | + $this->engines = $engines; |
|
100 | + $this->events = $events; |
|
101 | 101 | |
102 | - $this->share('__env', $this); |
|
103 | - } |
|
102 | + $this->share('__env', $this); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Check existance view file. |
|
107 | - * |
|
108 | - * @param string $view |
|
109 | - * |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function viewExists($view): bool |
|
113 | - { |
|
114 | - try { |
|
115 | - $this->finder->find($view); |
|
116 | - } catch(InvalidArgumentException $e) { |
|
117 | - return false; |
|
118 | - } |
|
105 | + /** |
|
106 | + * Check existance view file. |
|
107 | + * |
|
108 | + * @param string $view |
|
109 | + * |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function viewExists($view): bool |
|
113 | + { |
|
114 | + try { |
|
115 | + $this->finder->find($view); |
|
116 | + } catch(InvalidArgumentException $e) { |
|
117 | + return false; |
|
118 | + } |
|
119 | 119 | |
120 | - return true; |
|
121 | - } |
|
120 | + return true; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Global and local data are merged and extracted to create local variables within the view file. |
|
125 | - * Renders the view object to a string. |
|
126 | - * |
|
127 | - * @example $output = $view->make(); |
|
128 | - * |
|
129 | - * @param string $view View filename |
|
130 | - * @param array $data Array of values |
|
131 | - * |
|
132 | - * @return \Syscodes\Components\Contracts\View\View |
|
133 | - */ |
|
134 | - public function make($view, $data = []) |
|
135 | - { |
|
136 | - $path = $this->finder->find( |
|
137 | - $view = $this->normalizeName($view) |
|
138 | - ); |
|
123 | + /** |
|
124 | + * Global and local data are merged and extracted to create local variables within the view file. |
|
125 | + * Renders the view object to a string. |
|
126 | + * |
|
127 | + * @example $output = $view->make(); |
|
128 | + * |
|
129 | + * @param string $view View filename |
|
130 | + * @param array $data Array of values |
|
131 | + * |
|
132 | + * @return \Syscodes\Components\Contracts\View\View |
|
133 | + */ |
|
134 | + public function make($view, $data = []) |
|
135 | + { |
|
136 | + $path = $this->finder->find( |
|
137 | + $view = $this->normalizeName($view) |
|
138 | + ); |
|
139 | 139 | |
140 | - // Loader class instance. |
|
141 | - return take($this->viewInstance($view, $path, $data), fn ($view) => $this->callCreator($view)); |
|
142 | - } |
|
140 | + // Loader class instance. |
|
141 | + return take($this->viewInstance($view, $path, $data), fn ($view) => $this->callCreator($view)); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Normalize a view name. |
|
146 | - * |
|
147 | - * @param string $name |
|
148 | - * |
|
149 | - * @return string |
|
150 | - */ |
|
151 | - protected function normalizeName($name): string |
|
152 | - { |
|
153 | - return ViewName::normalize($name); |
|
154 | - } |
|
144 | + /** |
|
145 | + * Normalize a view name. |
|
146 | + * |
|
147 | + * @param string $name |
|
148 | + * |
|
149 | + * @return string |
|
150 | + */ |
|
151 | + protected function normalizeName($name): string |
|
152 | + { |
|
153 | + return ViewName::normalize($name); |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * Create a new view instance from the given arguments. |
|
158 | - * |
|
159 | - * @param string $file View filename |
|
160 | - * @param string $path Path filename |
|
161 | - * @param array $data Array of values |
|
162 | - * |
|
163 | - * @return \Syscodes\Components\Contracts\View\View |
|
164 | - */ |
|
165 | - protected function viewInstance($view, $path, $data) |
|
166 | - { |
|
167 | - return new View($this, $this->getEngineFromPath($path), $view, $path, $data); |
|
168 | - } |
|
156 | + /** |
|
157 | + * Create a new view instance from the given arguments. |
|
158 | + * |
|
159 | + * @param string $file View filename |
|
160 | + * @param string $path Path filename |
|
161 | + * @param array $data Array of values |
|
162 | + * |
|
163 | + * @return \Syscodes\Components\Contracts\View\View |
|
164 | + */ |
|
165 | + protected function viewInstance($view, $path, $data) |
|
166 | + { |
|
167 | + return new View($this, $this->getEngineFromPath($path), $view, $path, $data); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Get the appropriate view engine for the given path. |
|
172 | - * |
|
173 | - * @param string $path |
|
174 | - * |
|
175 | - * @return \Syscodes\Components\Contracts\View\Engine |
|
176 | - * |
|
177 | - * @throws \InvalidArgumentException |
|
178 | - */ |
|
179 | - public function getEngineFromPath($path) |
|
180 | - { |
|
181 | - if ( ! $extension = $this->getExtension($path)) { |
|
182 | - throw new InvalidArgumentException("Unrecognized extension in file: {$path}"); |
|
183 | - } |
|
170 | + /** |
|
171 | + * Get the appropriate view engine for the given path. |
|
172 | + * |
|
173 | + * @param string $path |
|
174 | + * |
|
175 | + * @return \Syscodes\Components\Contracts\View\Engine |
|
176 | + * |
|
177 | + * @throws \InvalidArgumentException |
|
178 | + */ |
|
179 | + public function getEngineFromPath($path) |
|
180 | + { |
|
181 | + if ( ! $extension = $this->getExtension($path)) { |
|
182 | + throw new InvalidArgumentException("Unrecognized extension in file: {$path}"); |
|
183 | + } |
|
184 | 184 | |
185 | - $engine = $this->extensions[$extension]; |
|
185 | + $engine = $this->extensions[$extension]; |
|
186 | 186 | |
187 | - return $this->engines->resolve($engine); |
|
188 | - } |
|
187 | + return $this->engines->resolve($engine); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * Get the extension used by the view file. |
|
192 | - * |
|
193 | - * @param string $path |
|
194 | - * |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - protected function getExtension($path) |
|
198 | - { |
|
199 | - $extensions = array_keys($this->extensions); |
|
190 | + /** |
|
191 | + * Get the extension used by the view file. |
|
192 | + * |
|
193 | + * @param string $path |
|
194 | + * |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + protected function getExtension($path) |
|
198 | + { |
|
199 | + $extensions = array_keys($this->extensions); |
|
200 | 200 | |
201 | - return Arr::first($extensions, fn ($value) => Str::endsWith($path, '.'.$value)); |
|
202 | - } |
|
201 | + return Arr::first($extensions, fn ($value) => Str::endsWith($path, '.'.$value)); |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Call the creator for a given view. |
|
206 | - * |
|
207 | - * @param \Syscodes\Components\View\View $view |
|
208 | - * |
|
209 | - * @return void |
|
210 | - */ |
|
211 | - public function callCreator(View $view): void |
|
212 | - { |
|
213 | - $this->events->dispatch('creating: '.$view->getView(), [$view]); |
|
214 | - } |
|
204 | + /** |
|
205 | + * Call the creator for a given view. |
|
206 | + * |
|
207 | + * @param \Syscodes\Components\View\View $view |
|
208 | + * |
|
209 | + * @return void |
|
210 | + */ |
|
211 | + public function callCreator(View $view): void |
|
212 | + { |
|
213 | + $this->events->dispatch('creating: '.$view->getView(), [$view]); |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Get the extension to engine bindings. |
|
218 | - * |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function getExtensions(): array |
|
222 | - { |
|
223 | - return $this->extensions; |
|
224 | - } |
|
216 | + /** |
|
217 | + * Get the extension to engine bindings. |
|
218 | + * |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function getExtensions(): array |
|
222 | + { |
|
223 | + return $this->extensions; |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * Add a piece of shared data to the environment. |
|
228 | - * |
|
229 | - * @param array|string $key |
|
230 | - * @param mixed|null $value |
|
231 | - * |
|
232 | - * @return mixed |
|
233 | - */ |
|
234 | - public function share($key, $value = null) |
|
235 | - { |
|
236 | - $keys = is_array($key) ? $key : [$key => $value]; |
|
226 | + /** |
|
227 | + * Add a piece of shared data to the environment. |
|
228 | + * |
|
229 | + * @param array|string $key |
|
230 | + * @param mixed|null $value |
|
231 | + * |
|
232 | + * @return mixed |
|
233 | + */ |
|
234 | + public function share($key, $value = null) |
|
235 | + { |
|
236 | + $keys = is_array($key) ? $key : [$key => $value]; |
|
237 | 237 | |
238 | - foreach ($keys as $key => $value) { |
|
239 | - $this->shared[$key] = $value; |
|
240 | - } |
|
238 | + foreach ($keys as $key => $value) { |
|
239 | + $this->shared[$key] = $value; |
|
240 | + } |
|
241 | 241 | |
242 | - return $value; |
|
243 | - } |
|
242 | + return $value; |
|
243 | + } |
|
244 | 244 | |
245 | - /** |
|
246 | - * Replace the namespace hints for the given namespace. |
|
247 | - * |
|
248 | - * @param string $namespace |
|
249 | - * @param string|array $hints |
|
250 | - * |
|
251 | - * @return self |
|
252 | - */ |
|
253 | - public function replaceNamespace($namespace, $hints): self |
|
254 | - { |
|
255 | - $this->finder->replaceNamespace($namespace, $hints); |
|
245 | + /** |
|
246 | + * Replace the namespace hints for the given namespace. |
|
247 | + * |
|
248 | + * @param string $namespace |
|
249 | + * @param string|array $hints |
|
250 | + * |
|
251 | + * @return self |
|
252 | + */ |
|
253 | + public function replaceNamespace($namespace, $hints): self |
|
254 | + { |
|
255 | + $this->finder->replaceNamespace($namespace, $hints); |
|
256 | 256 | |
257 | - return $this; |
|
258 | - } |
|
257 | + return $this; |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * Increment the rendering counter. |
|
262 | - * |
|
263 | - * @return int |
|
264 | - */ |
|
265 | - public function increment(): int |
|
266 | - { |
|
267 | - return $this->renderCount++; |
|
268 | - } |
|
260 | + /** |
|
261 | + * Increment the rendering counter. |
|
262 | + * |
|
263 | + * @return int |
|
264 | + */ |
|
265 | + public function increment(): int |
|
266 | + { |
|
267 | + return $this->renderCount++; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Decrement the rendering counter. |
|
272 | - * |
|
273 | - * @return int |
|
274 | - */ |
|
275 | - public function decrement(): int |
|
276 | - { |
|
277 | - return $this->renderCount--; |
|
278 | - } |
|
270 | + /** |
|
271 | + * Decrement the rendering counter. |
|
272 | + * |
|
273 | + * @return int |
|
274 | + */ |
|
275 | + public function decrement(): int |
|
276 | + { |
|
277 | + return $this->renderCount--; |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * Check if there are no active render operations. |
|
282 | - * |
|
283 | - * @return bool |
|
284 | - */ |
|
285 | - public function doneRendering(): bool |
|
286 | - { |
|
287 | - return $this->renderCount == 0; |
|
288 | - } |
|
280 | + /** |
|
281 | + * Check if there are no active render operations. |
|
282 | + * |
|
283 | + * @return bool |
|
284 | + */ |
|
285 | + public function doneRendering(): bool |
|
286 | + { |
|
287 | + return $this->renderCount == 0; |
|
288 | + } |
|
289 | 289 | |
290 | - /** |
|
291 | - * Flush all of the parser state like sections. |
|
292 | - * |
|
293 | - * @return void |
|
294 | - */ |
|
295 | - public function flushState(): void |
|
296 | - { |
|
297 | - $this->renderCount = 0; |
|
290 | + /** |
|
291 | + * Flush all of the parser state like sections. |
|
292 | + * |
|
293 | + * @return void |
|
294 | + */ |
|
295 | + public function flushState(): void |
|
296 | + { |
|
297 | + $this->renderCount = 0; |
|
298 | 298 | |
299 | - $this->flushSections(); |
|
300 | - } |
|
299 | + $this->flushSections(); |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * Flush all of the section contents if done rendering. |
|
304 | - * |
|
305 | - * @return void |
|
306 | - */ |
|
307 | - public function flushStateIfDoneRendering(): void |
|
308 | - { |
|
309 | - if ($this->doneRendering()) { |
|
310 | - $this->flushState(); |
|
311 | - } |
|
312 | - } |
|
302 | + /** |
|
303 | + * Flush all of the section contents if done rendering. |
|
304 | + * |
|
305 | + * @return void |
|
306 | + */ |
|
307 | + public function flushStateIfDoneRendering(): void |
|
308 | + { |
|
309 | + if ($this->doneRendering()) { |
|
310 | + $this->flushState(); |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * Get all of the shared data for the environment. |
|
316 | - * |
|
317 | - * @return array |
|
318 | - */ |
|
319 | - public function getShared(): array |
|
320 | - { |
|
321 | - return $this->shared; |
|
322 | - } |
|
314 | + /** |
|
315 | + * Get all of the shared data for the environment. |
|
316 | + * |
|
317 | + * @return array |
|
318 | + */ |
|
319 | + public function getShared(): array |
|
320 | + { |
|
321 | + return $this->shared; |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * Get the IoC container instance. |
|
326 | - * |
|
327 | - * @return \Syscodes\Components\Contracts\Container\Container |
|
328 | - */ |
|
329 | - public function getContainer() |
|
330 | - { |
|
331 | - return $this->container; |
|
332 | - } |
|
324 | + /** |
|
325 | + * Get the IoC container instance. |
|
326 | + * |
|
327 | + * @return \Syscodes\Components\Contracts\Container\Container |
|
328 | + */ |
|
329 | + public function getContainer() |
|
330 | + { |
|
331 | + return $this->container; |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Set the IoC container instance. |
|
336 | - * |
|
337 | - * @param \Syscodes\Components\Contracts\Container\Container $container |
|
338 | - * |
|
339 | - * @return void |
|
340 | - */ |
|
341 | - public function setContainer(Container $container): void |
|
342 | - { |
|
343 | - $this->container = $container; |
|
344 | - } |
|
334 | + /** |
|
335 | + * Set the IoC container instance. |
|
336 | + * |
|
337 | + * @param \Syscodes\Components\Contracts\Container\Container $container |
|
338 | + * |
|
339 | + * @return void |
|
340 | + */ |
|
341 | + public function setContainer(Container $container): void |
|
342 | + { |
|
343 | + $this->container = $container; |
|
344 | + } |
|
345 | 345 | } |
346 | 346 | \ No newline at end of file |
@@ -113,7 +113,7 @@ |
||
113 | 113 | { |
114 | 114 | try { |
115 | 115 | $this->finder->find($view); |
116 | - } catch(InvalidArgumentException $e) { |
|
116 | + } catch (InvalidArgumentException $e) { |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function stopPush() |
80 | 80 | { |
81 | 81 | if (empty($this->pushStack)) { |
82 | - throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
82 | + throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | return take(array_pop($this->pushStack), function ($last) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function stopPrepend() |
138 | 138 | { |
139 | 139 | if (empty($this->pushStack)) { |
140 | - throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
140 | + throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return take(array_pop($this->pushStack), function ($last) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
83 | 83 | } |
84 | 84 | |
85 | - return take(array_pop($this->pushStack), function ($last) { |
|
85 | + return take(array_pop($this->pushStack), function($last) { |
|
86 | 86 | $this->extendPush($last, ob_get_clean()); |
87 | 87 | }); |
88 | 88 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
141 | 141 | } |
142 | 142 | |
143 | - return take(array_pop($this->pushStack), function ($last) { |
|
143 | + return take(array_pop($this->pushStack), function($last) { |
|
144 | 144 | $this->extendPrepend($last, ob_get_clean()); |
145 | 145 | }); |
146 | 146 | } |
@@ -30,191 +30,191 @@ |
||
30 | 30 | */ |
31 | 31 | trait ManagesLayouts |
32 | 32 | { |
33 | - /** |
|
34 | - * Started blocks. |
|
35 | - * |
|
36 | - * @var array $sections |
|
37 | - */ |
|
38 | - protected $sections = []; |
|
33 | + /** |
|
34 | + * Started blocks. |
|
35 | + * |
|
36 | + * @var array $sections |
|
37 | + */ |
|
38 | + protected $sections = []; |
|
39 | 39 | |
40 | - /** |
|
41 | - * The stack of in-progress sections. |
|
42 | - * |
|
43 | - * @var array $sectionStack |
|
44 | - */ |
|
45 | - protected $sectionStack = []; |
|
40 | + /** |
|
41 | + * The stack of in-progress sections. |
|
42 | + * |
|
43 | + * @var array $sectionStack |
|
44 | + */ |
|
45 | + protected $sectionStack = []; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Starting section. |
|
49 | - * |
|
50 | - * @param string $section |
|
51 | - * @param string|null $content |
|
52 | - * |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function startSection($section, $content = null) |
|
56 | - { |
|
57 | - if (null === $content) { |
|
58 | - if (ob_start()) { |
|
59 | - $this->sectionStack[] = $section; |
|
60 | - } |
|
61 | - } else { |
|
62 | - $this->extendSection($section, $content instanceof View ? $content : e($content)); |
|
63 | - } |
|
64 | - } |
|
47 | + /** |
|
48 | + * Starting section. |
|
49 | + * |
|
50 | + * @param string $section |
|
51 | + * @param string|null $content |
|
52 | + * |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function startSection($section, $content = null) |
|
56 | + { |
|
57 | + if (null === $content) { |
|
58 | + if (ob_start()) { |
|
59 | + $this->sectionStack[] = $section; |
|
60 | + } |
|
61 | + } else { |
|
62 | + $this->extendSection($section, $content instanceof View ? $content : e($content)); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Inject inline content into a section. |
|
68 | - * |
|
69 | - * @param string $section |
|
70 | - * @param string $content |
|
71 | - * |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function injectSection($section, $content) |
|
75 | - { |
|
76 | - $this->beginSection($section, $content); |
|
77 | - } |
|
66 | + /** |
|
67 | + * Inject inline content into a section. |
|
68 | + * |
|
69 | + * @param string $section |
|
70 | + * @param string $content |
|
71 | + * |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function injectSection($section, $content) |
|
75 | + { |
|
76 | + $this->beginSection($section, $content); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Append content to a given section. |
|
81 | - * |
|
82 | - * @param string $section |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - protected function extendSection($section, $content) |
|
88 | - { |
|
89 | - if (isset($this->sections[$section])) { |
|
90 | - $content = str_replace(static::parent(), $content, $this->sections[$section]); |
|
91 | - } |
|
79 | + /** |
|
80 | + * Append content to a given section. |
|
81 | + * |
|
82 | + * @param string $section |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + protected function extendSection($section, $content) |
|
88 | + { |
|
89 | + if (isset($this->sections[$section])) { |
|
90 | + $content = str_replace(static::parent(), $content, $this->sections[$section]); |
|
91 | + } |
|
92 | 92 | |
93 | - $this->sections[$section] = $content; |
|
94 | - } |
|
93 | + $this->sections[$section] = $content; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Close and printing section. |
|
98 | - * |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function showSection(): string |
|
102 | - { |
|
103 | - if (empty($this->sectionStack)) { |
|
104 | - return ''; |
|
105 | - } |
|
96 | + /** |
|
97 | + * Close and printing section. |
|
98 | + * |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function showSection(): string |
|
102 | + { |
|
103 | + if (empty($this->sectionStack)) { |
|
104 | + return ''; |
|
105 | + } |
|
106 | 106 | |
107 | - return $this->giveContent($this->stopSection()); |
|
108 | - } |
|
107 | + return $this->giveContent($this->stopSection()); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Give sections the page view from the master page. |
|
112 | - * |
|
113 | - * @param string $name |
|
114 | - * |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function giveContent($name, $default = ''): string |
|
118 | - { |
|
119 | - $sectionContent = $default instanceof View ? $default : e($default); |
|
110 | + /** |
|
111 | + * Give sections the page view from the master page. |
|
112 | + * |
|
113 | + * @param string $name |
|
114 | + * |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function giveContent($name, $default = ''): string |
|
118 | + { |
|
119 | + $sectionContent = $default instanceof View ? $default : e($default); |
|
120 | 120 | |
121 | - if (isset($this->sections[$name])) { |
|
122 | - $sectionContent = $this->sections[$name]; |
|
123 | - } |
|
121 | + if (isset($this->sections[$name])) { |
|
122 | + $sectionContent = $this->sections[$name]; |
|
123 | + } |
|
124 | 124 | |
125 | - return str_replace(static::parent(), '', $sectionContent); |
|
126 | - } |
|
125 | + return str_replace(static::parent(), '', $sectionContent); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Closing section. |
|
130 | - * |
|
131 | - * @param bool $overwrite |
|
132 | - * |
|
133 | - * @return mixed |
|
134 | - * |
|
135 | - * @throws \InvalidArgumentException |
|
136 | - */ |
|
137 | - public function stopSection($overwrite = false) |
|
138 | - { |
|
139 | - if (empty($this->sectionStack)) { |
|
140 | - throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
141 | - } |
|
128 | + /** |
|
129 | + * Closing section. |
|
130 | + * |
|
131 | + * @param bool $overwrite |
|
132 | + * |
|
133 | + * @return mixed |
|
134 | + * |
|
135 | + * @throws \InvalidArgumentException |
|
136 | + */ |
|
137 | + public function stopSection($overwrite = false) |
|
138 | + { |
|
139 | + if (empty($this->sectionStack)) { |
|
140 | + throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
141 | + } |
|
142 | 142 | |
143 | - $last = array_pop($this->sectionStack); |
|
143 | + $last = array_pop($this->sectionStack); |
|
144 | 144 | |
145 | - if ($overwrite) { |
|
146 | - $this->sections[$last] = ob_get_clean(); |
|
147 | - } else { |
|
148 | - $this->extendSection($last, ob_get_clean()); |
|
149 | - } |
|
145 | + if ($overwrite) { |
|
146 | + $this->sections[$last] = ob_get_clean(); |
|
147 | + } else { |
|
148 | + $this->extendSection($last, ob_get_clean()); |
|
149 | + } |
|
150 | 150 | |
151 | - return $last; |
|
152 | - } |
|
151 | + return $last; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Stop injecting content into a section and append it. |
|
156 | - * |
|
157 | - * @return string |
|
158 | - * |
|
159 | - * @throws \InvalidArgumentException |
|
160 | - */ |
|
161 | - public function appendSection() |
|
162 | - { |
|
163 | - if (empty($this->sectionStack)) { |
|
164 | - throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
165 | - } |
|
154 | + /** |
|
155 | + * Stop injecting content into a section and append it. |
|
156 | + * |
|
157 | + * @return string |
|
158 | + * |
|
159 | + * @throws \InvalidArgumentException |
|
160 | + */ |
|
161 | + public function appendSection() |
|
162 | + { |
|
163 | + if (empty($this->sectionStack)) { |
|
164 | + throw new InvalidArgumentException('You cannot finish a section without first starting with one.'); |
|
165 | + } |
|
166 | 166 | |
167 | - $last = array_pop($this->sectionStack); |
|
167 | + $last = array_pop($this->sectionStack); |
|
168 | 168 | |
169 | - if (isset($this->sections[$last])) { |
|
170 | - $this->sections[$last] .= ob_get_clean(); |
|
171 | - } else { |
|
172 | - $this->sections[$last] = ob_get_clean(); |
|
173 | - } |
|
169 | + if (isset($this->sections[$last])) { |
|
170 | + $this->sections[$last] .= ob_get_clean(); |
|
171 | + } else { |
|
172 | + $this->sections[$last] = ob_get_clean(); |
|
173 | + } |
|
174 | 174 | |
175 | - return $last; |
|
176 | - } |
|
175 | + return $last; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Check if section exists. |
|
180 | - * |
|
181 | - * @param string $name |
|
182 | - * |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function hasSection($name): bool |
|
186 | - { |
|
187 | - return array_key_exists($name, $this->sections); |
|
188 | - } |
|
178 | + /** |
|
179 | + * Check if section exists. |
|
180 | + * |
|
181 | + * @param string $name |
|
182 | + * |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function hasSection($name): bool |
|
186 | + { |
|
187 | + return array_key_exists($name, $this->sections); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * Get the entire array of sections. |
|
192 | - * |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - public function getSections(): array |
|
196 | - { |
|
197 | - return $this->sections; |
|
198 | - } |
|
190 | + /** |
|
191 | + * Get the entire array of sections. |
|
192 | + * |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + public function getSections(): array |
|
196 | + { |
|
197 | + return $this->sections; |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * Replace the @parent directive to a placeholder. |
|
202 | - * |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public static function parent(): string |
|
206 | - { |
|
207 | - return '@parent'; |
|
208 | - } |
|
200 | + /** |
|
201 | + * Replace the @parent directive to a placeholder. |
|
202 | + * |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public static function parent(): string |
|
206 | + { |
|
207 | + return '@parent'; |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * Flush all of the section contents. |
|
212 | - * |
|
213 | - * @return void |
|
214 | - */ |
|
215 | - public function flushSections(): void |
|
216 | - { |
|
217 | - $this->sections = []; |
|
218 | - $this->sectionStack = []; |
|
219 | - } |
|
210 | + /** |
|
211 | + * Flush all of the section contents. |
|
212 | + * |
|
213 | + * @return void |
|
214 | + */ |
|
215 | + public function flushSections(): void |
|
216 | + { |
|
217 | + $this->sections = []; |
|
218 | + $this->sectionStack = []; |
|
219 | + } |
|
220 | 220 | } |
221 | 221 | \ No newline at end of file |
@@ -332,29 +332,29 @@ |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | - public function if($name, callable $callback): void |
|
335 | + public function if ($name, callable $callback): void |
|
336 | 336 | { |
337 | 337 | $this->conditions[$name] = $callback; |
338 | 338 | |
339 | - $this->directive($name, function ($expression) use ($name) { |
|
339 | + $this->directive($name, function($expression) use ($name) { |
|
340 | 340 | return $expression !== '' |
341 | 341 | ? "<?php if (\Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}', {$expression})): ?>" |
342 | 342 | : "<?php if (\Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}')): ?>"; |
343 | 343 | }); |
344 | 344 | |
345 | - $this->directive('unless'.$name, function ($expression) use ($name) { |
|
345 | + $this->directive('unless'.$name, function($expression) use ($name) { |
|
346 | 346 | return $expression !== '' |
347 | 347 | ? "<?php if (! \Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}', {$expression})): ?>" |
348 | 348 | : "<?php if (! \Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}')): ?>"; |
349 | 349 | }); |
350 | 350 | |
351 | - $this->directive('else'.$name, function ($expression) use ($name) { |
|
351 | + $this->directive('else'.$name, function($expression) use ($name) { |
|
352 | 352 | return $expression !== '' |
353 | 353 | ? "<?php elseif (\Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}', {$expression})): ?>" |
354 | 354 | : "<?php elseif (\Syscodes\Components\Support\Facades\Plaze::checkpoint('{$name}')): ?>"; |
355 | 355 | }); |
356 | 356 | |
357 | - $this->directive('end'.$name, function () { |
|
357 | + $this->directive('end'.$name, function() { |
|
358 | 358 | return '<?php endif; ?>'; |
359 | 359 | }); |
360 | 360 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | return $this->files->lastModified($path) >= |
95 | - $this->files->lastModified($compiled); |
|
95 | + $this->files->lastModified($compiled); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -43,510 +43,510 @@ |
||
43 | 43 | */ |
44 | 44 | class View implements ArrayAccess, Webable, ViewContract |
45 | 45 | { |
46 | - use Macroable { |
|
47 | - __call as macroCall; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Array of local variables. |
|
52 | - * |
|
53 | - * @var array $data |
|
54 | - */ |
|
55 | - protected $data = []; |
|
56 | - |
|
57 | - /** |
|
58 | - * The engine implementation. |
|
59 | - * |
|
60 | - * @var \Syscodes\Components\Contracts\View\Engine $engine |
|
61 | - */ |
|
62 | - protected $engine; |
|
63 | - |
|
64 | - /** |
|
65 | - * The view factory instance. |
|
66 | - * |
|
67 | - * @var \Syscodes\Components\View\factory $factory |
|
68 | - */ |
|
69 | - protected $factory; |
|
70 | - |
|
71 | - /** |
|
72 | - * The path to the view file. |
|
73 | - * |
|
74 | - * @var string $path |
|
75 | - */ |
|
76 | - protected $path; |
|
77 | - |
|
78 | - /** |
|
79 | - * Get the name of the view. |
|
80 | - * |
|
81 | - * @var string $view |
|
82 | - */ |
|
83 | - protected $view; |
|
84 | - |
|
85 | - /** |
|
86 | - * Constructor: Create a new view instance. |
|
87 | - * |
|
88 | - * @param \Syscodes\Components\View\factory $factory |
|
89 | - * @param \Syscodes\Components\Contracts\View\Engine $engine |
|
90 | - * @param string $view |
|
91 | - * @param string $path |
|
92 | - * @param array $data |
|
93 | - * |
|
94 | - * @return void |
|
95 | - * |
|
96 | - * @throws \InvalidArgumentException |
|
97 | - */ |
|
98 | - public function __construct( |
|
99 | - Factory $factory, |
|
100 | - Engine $engine, |
|
101 | - $view, |
|
102 | - $path, |
|
103 | - $data = [] |
|
104 | - ) { |
|
105 | - $this->factory = $factory; |
|
106 | - $this->engine = $engine; |
|
107 | - $this->view = $view; |
|
108 | - $this->path = $path; |
|
109 | - $this->data = $data instanceof Arrayable ? $data->toArray() : (array) $data; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Get the string contents of the view. |
|
114 | - * |
|
115 | - * @example View::render(); |
|
116 | - * |
|
117 | - * @param \Callable|null $callback |
|
118 | - * |
|
119 | - * @return array|string |
|
120 | - * |
|
121 | - * @throws \Throwable |
|
122 | - */ |
|
123 | - public function render(Callable $callback = null) |
|
124 | - { |
|
125 | - try { |
|
126 | - $contents = $this->renderContents(); |
|
127 | - |
|
128 | - $response = isset($callback) ? $callback($this, $contents) : null; |
|
129 | - |
|
130 | - $this->factory->flushStateIfDoneRendering(); |
|
131 | - |
|
132 | - return ! is_null($response) ? $response : $contents; |
|
133 | - } catch(Throwable $e) { |
|
134 | - $this->factory->flushState(); |
|
135 | - |
|
136 | - throw $e; |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Get the contents of the view instance. |
|
142 | - * |
|
143 | - * @return void |
|
144 | - */ |
|
145 | - protected function renderContents() |
|
146 | - { |
|
147 | - $this->factory->increment(); |
|
148 | - |
|
149 | - $contents = $this->getContents(); |
|
150 | - |
|
151 | - $this->factory->decrement(); |
|
152 | - |
|
153 | - return $contents; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Get the evaluated contents of the view. |
|
158 | - * |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - protected function getContents(): string |
|
162 | - { |
|
163 | - return $this->engine->get($this->path, $this->getArrayData()); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * The view data will be extracted. |
|
168 | - * |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - public function getArrayData(): array |
|
172 | - { |
|
173 | - $data = array_merge($this->factory->getShared(), $this->data); |
|
46 | + use Macroable { |
|
47 | + __call as macroCall; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Array of local variables. |
|
52 | + * |
|
53 | + * @var array $data |
|
54 | + */ |
|
55 | + protected $data = []; |
|
56 | + |
|
57 | + /** |
|
58 | + * The engine implementation. |
|
59 | + * |
|
60 | + * @var \Syscodes\Components\Contracts\View\Engine $engine |
|
61 | + */ |
|
62 | + protected $engine; |
|
63 | + |
|
64 | + /** |
|
65 | + * The view factory instance. |
|
66 | + * |
|
67 | + * @var \Syscodes\Components\View\factory $factory |
|
68 | + */ |
|
69 | + protected $factory; |
|
70 | + |
|
71 | + /** |
|
72 | + * The path to the view file. |
|
73 | + * |
|
74 | + * @var string $path |
|
75 | + */ |
|
76 | + protected $path; |
|
77 | + |
|
78 | + /** |
|
79 | + * Get the name of the view. |
|
80 | + * |
|
81 | + * @var string $view |
|
82 | + */ |
|
83 | + protected $view; |
|
84 | + |
|
85 | + /** |
|
86 | + * Constructor: Create a new view instance. |
|
87 | + * |
|
88 | + * @param \Syscodes\Components\View\factory $factory |
|
89 | + * @param \Syscodes\Components\Contracts\View\Engine $engine |
|
90 | + * @param string $view |
|
91 | + * @param string $path |
|
92 | + * @param array $data |
|
93 | + * |
|
94 | + * @return void |
|
95 | + * |
|
96 | + * @throws \InvalidArgumentException |
|
97 | + */ |
|
98 | + public function __construct( |
|
99 | + Factory $factory, |
|
100 | + Engine $engine, |
|
101 | + $view, |
|
102 | + $path, |
|
103 | + $data = [] |
|
104 | + ) { |
|
105 | + $this->factory = $factory; |
|
106 | + $this->engine = $engine; |
|
107 | + $this->view = $view; |
|
108 | + $this->path = $path; |
|
109 | + $this->data = $data instanceof Arrayable ? $data->toArray() : (array) $data; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Get the string contents of the view. |
|
114 | + * |
|
115 | + * @example View::render(); |
|
116 | + * |
|
117 | + * @param \Callable|null $callback |
|
118 | + * |
|
119 | + * @return array|string |
|
120 | + * |
|
121 | + * @throws \Throwable |
|
122 | + */ |
|
123 | + public function render(Callable $callback = null) |
|
124 | + { |
|
125 | + try { |
|
126 | + $contents = $this->renderContents(); |
|
127 | + |
|
128 | + $response = isset($callback) ? $callback($this, $contents) : null; |
|
129 | + |
|
130 | + $this->factory->flushStateIfDoneRendering(); |
|
131 | + |
|
132 | + return ! is_null($response) ? $response : $contents; |
|
133 | + } catch(Throwable $e) { |
|
134 | + $this->factory->flushState(); |
|
135 | + |
|
136 | + throw $e; |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Get the contents of the view instance. |
|
142 | + * |
|
143 | + * @return void |
|
144 | + */ |
|
145 | + protected function renderContents() |
|
146 | + { |
|
147 | + $this->factory->increment(); |
|
148 | + |
|
149 | + $contents = $this->getContents(); |
|
150 | + |
|
151 | + $this->factory->decrement(); |
|
152 | + |
|
153 | + return $contents; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Get the evaluated contents of the view. |
|
158 | + * |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + protected function getContents(): string |
|
162 | + { |
|
163 | + return $this->engine->get($this->path, $this->getArrayData()); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * The view data will be extracted. |
|
168 | + * |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + public function getArrayData(): array |
|
172 | + { |
|
173 | + $data = array_merge($this->factory->getShared(), $this->data); |
|
174 | 174 | |
175 | - return array_map(fn ($value) => ($value instanceof Renderable) ? $value->render() : $value, $data); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Get the sections of the rendered view. |
|
180 | - * |
|
181 | - * @return array |
|
182 | - * |
|
183 | - * @throws \Throwable |
|
184 | - */ |
|
185 | - public function renderSections() |
|
186 | - { |
|
187 | - return $this->render(fn () => $this->factory->getSections()); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Add a piece of data to the view. |
|
192 | - * |
|
193 | - * @example $view->assign($content, $data); |
|
194 | - * |
|
195 | - * @param string|array $key |
|
196 | - * @param mixed $value |
|
197 | - * |
|
198 | - * @return static |
|
199 | - */ |
|
200 | - public function assign($key, $value = null): static |
|
201 | - { |
|
202 | - if (is_array($key)) { |
|
203 | - $this->data = array_merge($this->data, $key); |
|
204 | - } else { |
|
205 | - $this->data[$key] = $value; |
|
206 | - } |
|
207 | - |
|
208 | - return $this; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Assigns a value by reference. The benefit of binding is that values can be altered |
|
213 | - * without re-setting them. It is also possible to bind variables before they have values. |
|
214 | - * Assigned values will be available as a variable within the view file: |
|
215 | - * |
|
216 | - * @example $view->bind('ref', $bar); |
|
217 | - * |
|
218 | - * @param string $key Variable name |
|
219 | - * @param mixed $value Referenced variable |
|
220 | - * |
|
221 | - * @return static |
|
222 | - */ |
|
223 | - public function bind($key, & $value): static |
|
224 | - { |
|
225 | - $this->data[$key] =& $value; |
|
226 | - |
|
227 | - return $this; |
|
228 | - } |
|
175 | + return array_map(fn ($value) => ($value instanceof Renderable) ? $value->render() : $value, $data); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Get the sections of the rendered view. |
|
180 | + * |
|
181 | + * @return array |
|
182 | + * |
|
183 | + * @throws \Throwable |
|
184 | + */ |
|
185 | + public function renderSections() |
|
186 | + { |
|
187 | + return $this->render(fn () => $this->factory->getSections()); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Add a piece of data to the view. |
|
192 | + * |
|
193 | + * @example $view->assign($content, $data); |
|
194 | + * |
|
195 | + * @param string|array $key |
|
196 | + * @param mixed $value |
|
197 | + * |
|
198 | + * @return static |
|
199 | + */ |
|
200 | + public function assign($key, $value = null): static |
|
201 | + { |
|
202 | + if (is_array($key)) { |
|
203 | + $this->data = array_merge($this->data, $key); |
|
204 | + } else { |
|
205 | + $this->data[$key] = $value; |
|
206 | + } |
|
207 | + |
|
208 | + return $this; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Assigns a value by reference. The benefit of binding is that values can be altered |
|
213 | + * without re-setting them. It is also possible to bind variables before they have values. |
|
214 | + * Assigned values will be available as a variable within the view file: |
|
215 | + * |
|
216 | + * @example $view->bind('ref', $bar); |
|
217 | + * |
|
218 | + * @param string $key Variable name |
|
219 | + * @param mixed $value Referenced variable |
|
220 | + * |
|
221 | + * @return static |
|
222 | + */ |
|
223 | + public function bind($key, & $value): static |
|
224 | + { |
|
225 | + $this->data[$key] =& $value; |
|
226 | + |
|
227 | + return $this; |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
231 | - * Add validation errors to the view. |
|
232 | - * |
|
233 | - * @param \Syscodes\Components\Contracts\Support\MessageProvider|array $provider |
|
234 | - * |
|
235 | - * @return static |
|
236 | - */ |
|
237 | - public function withErrors($provider): static |
|
238 | - { |
|
239 | - $this->with('errors', $this->formatErrors($provider)); |
|
230 | + /** |
|
231 | + * Add validation errors to the view. |
|
232 | + * |
|
233 | + * @param \Syscodes\Components\Contracts\Support\MessageProvider|array $provider |
|
234 | + * |
|
235 | + * @return static |
|
236 | + */ |
|
237 | + public function withErrors($provider): static |
|
238 | + { |
|
239 | + $this->with('errors', $this->formatErrors($provider)); |
|
240 | 240 | |
241 | - return $this; |
|
242 | - } |
|
241 | + return $this; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Format the given message provider into a MessageBag. |
|
246 | - * |
|
247 | - * @param \Syscodes\Components\Contracts\Support\MessageProvider|array $provider |
|
248 | - * |
|
249 | - * @return \Syscodes\Components\Support\MessageBag |
|
250 | - */ |
|
251 | - protected function formatErrors($provider) |
|
252 | - { |
|
253 | - return $provider instanceof MessageProvider |
|
254 | - ? $provider->getMessageBag() : new MessageBag((array) $provider); |
|
244 | + /** |
|
245 | + * Format the given message provider into a MessageBag. |
|
246 | + * |
|
247 | + * @param \Syscodes\Components\Contracts\Support\MessageProvider|array $provider |
|
248 | + * |
|
249 | + * @return \Syscodes\Components\Support\MessageBag |
|
250 | + */ |
|
251 | + protected function formatErrors($provider) |
|
252 | + { |
|
253 | + return $provider instanceof MessageProvider |
|
254 | + ? $provider->getMessageBag() : new MessageBag((array) $provider); |
|
255 | 255 | |
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Get the array of view data. |
|
260 | - * |
|
261 | - * @return array |
|
262 | - */ |
|
263 | - public function getData(): array |
|
264 | - { |
|
265 | - return $this->data; |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Get the name of the view. |
|
270 | - * |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public function getView(): string |
|
274 | - { |
|
275 | - return $this->view; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Get the path to the view file. |
|
280 | - * |
|
281 | - * @return string |
|
282 | - */ |
|
283 | - public function getPath(): string |
|
284 | - { |
|
285 | - return $this->path; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Set the path to the view file. |
|
290 | - * |
|
291 | - * @param string $path |
|
292 | - * |
|
293 | - * @return void |
|
294 | - */ |
|
295 | - public function setPath($path): void |
|
296 | - { |
|
297 | - $this->path = $path; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Get the view factory instance. |
|
302 | - * |
|
303 | - * @return \Syscodes\Components\View\factory |
|
304 | - */ |
|
305 | - public function getFactory() |
|
306 | - { |
|
307 | - return $this->factory; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * Get the view's rendering engine. |
|
312 | - * |
|
313 | - * @return \Syscodes\Components\Contracts\View\Engine |
|
314 | - */ |
|
315 | - public function getEngine() |
|
316 | - { |
|
317 | - return $this->engine; |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * Searches for the given variable and returns its value. |
|
322 | - * Local variables will be returned before global variables. |
|
323 | - * |
|
324 | - * @example $value = $view->get('foo', 'bar'); |
|
325 | - * |
|
326 | - * If the key is not given or null, the entire data array is returned. |
|
327 | - * |
|
328 | - * @param string $key The variable name |
|
329 | - * @param mixed $default The default value to return |
|
330 | - * |
|
331 | - * @return mixed |
|
332 | - * |
|
333 | - * @throws \InvalidArgumentException |
|
334 | - */ |
|
335 | - public function &get($key, $default = null) |
|
336 | - { |
|
337 | - if (strpos($key, '.') === false) { |
|
338 | - if (array_key_exists($key, $this->data)) { |
|
339 | - return $this->data[$key]; |
|
340 | - } else { |
|
341 | - throw new InvalidArgumentException(__('view.variableNotSet')); |
|
342 | - } |
|
343 | - } else { |
|
344 | - return value($default); |
|
345 | - } |
|
346 | - } |
|
347 | - |
|
348 | - /** |
|
349 | - * Assigns a variable by name. Assigned values will be available as a |
|
350 | - * variable within the view file: |
|
351 | - * |
|
352 | - * This value can be accessed as $var within the view |
|
353 | - * @example $view->set(array('food' => 'bread', 'beverage' => 'water')); |
|
354 | - * |
|
355 | - * @param string|array $key Variable name |
|
356 | - * @param mixed $value Value |
|
357 | - * |
|
358 | - * @return static |
|
359 | - */ |
|
360 | - public function set($key, $value = null): static |
|
361 | - { |
|
362 | - if (is_array($key) || $key instanceof Traversable) { |
|
363 | - foreach ($key as $name => $value) { |
|
364 | - $this->assign($name, $value); |
|
365 | - } |
|
366 | - } else { |
|
367 | - if (strpos($key, '.') === false) { |
|
368 | - $this->data[$key] = $value; |
|
369 | - } else { |
|
370 | - Arr::set($this->data, $key, $value); |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - return $this; |
|
375 | - } |
|
376 | - |
|
377 | - /* |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Get the array of view data. |
|
260 | + * |
|
261 | + * @return array |
|
262 | + */ |
|
263 | + public function getData(): array |
|
264 | + { |
|
265 | + return $this->data; |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Get the name of the view. |
|
270 | + * |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public function getView(): string |
|
274 | + { |
|
275 | + return $this->view; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Get the path to the view file. |
|
280 | + * |
|
281 | + * @return string |
|
282 | + */ |
|
283 | + public function getPath(): string |
|
284 | + { |
|
285 | + return $this->path; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Set the path to the view file. |
|
290 | + * |
|
291 | + * @param string $path |
|
292 | + * |
|
293 | + * @return void |
|
294 | + */ |
|
295 | + public function setPath($path): void |
|
296 | + { |
|
297 | + $this->path = $path; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Get the view factory instance. |
|
302 | + * |
|
303 | + * @return \Syscodes\Components\View\factory |
|
304 | + */ |
|
305 | + public function getFactory() |
|
306 | + { |
|
307 | + return $this->factory; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Get the view's rendering engine. |
|
312 | + * |
|
313 | + * @return \Syscodes\Components\Contracts\View\Engine |
|
314 | + */ |
|
315 | + public function getEngine() |
|
316 | + { |
|
317 | + return $this->engine; |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * Searches for the given variable and returns its value. |
|
322 | + * Local variables will be returned before global variables. |
|
323 | + * |
|
324 | + * @example $value = $view->get('foo', 'bar'); |
|
325 | + * |
|
326 | + * If the key is not given or null, the entire data array is returned. |
|
327 | + * |
|
328 | + * @param string $key The variable name |
|
329 | + * @param mixed $default The default value to return |
|
330 | + * |
|
331 | + * @return mixed |
|
332 | + * |
|
333 | + * @throws \InvalidArgumentException |
|
334 | + */ |
|
335 | + public function &get($key, $default = null) |
|
336 | + { |
|
337 | + if (strpos($key, '.') === false) { |
|
338 | + if (array_key_exists($key, $this->data)) { |
|
339 | + return $this->data[$key]; |
|
340 | + } else { |
|
341 | + throw new InvalidArgumentException(__('view.variableNotSet')); |
|
342 | + } |
|
343 | + } else { |
|
344 | + return value($default); |
|
345 | + } |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * Assigns a variable by name. Assigned values will be available as a |
|
350 | + * variable within the view file: |
|
351 | + * |
|
352 | + * This value can be accessed as $var within the view |
|
353 | + * @example $view->set(array('food' => 'bread', 'beverage' => 'water')); |
|
354 | + * |
|
355 | + * @param string|array $key Variable name |
|
356 | + * @param mixed $value Value |
|
357 | + * |
|
358 | + * @return static |
|
359 | + */ |
|
360 | + public function set($key, $value = null): static |
|
361 | + { |
|
362 | + if (is_array($key) || $key instanceof Traversable) { |
|
363 | + foreach ($key as $name => $value) { |
|
364 | + $this->assign($name, $value); |
|
365 | + } |
|
366 | + } else { |
|
367 | + if (strpos($key, '.') === false) { |
|
368 | + $this->data[$key] = $value; |
|
369 | + } else { |
|
370 | + Arr::set($this->data, $key, $value); |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + return $this; |
|
375 | + } |
|
376 | + |
|
377 | + /* |
|
378 | 378 | |----------------------------------------------------------------- |
379 | 379 | | ArrayAccess Methods |
380 | 380 | |----------------------------------------------------------------- |
381 | 381 | */ |
382 | 382 | |
383 | - /** |
|
384 | - * Whether or not an offset exists. |
|
385 | - * |
|
386 | - * @param string $offset |
|
387 | - * |
|
388 | - * @return bool |
|
389 | - */ |
|
390 | - public function offsetExists($offset): bool |
|
391 | - { |
|
392 | - return array_key_exists($offset, $this->data); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Returns the value at specified offset. |
|
397 | - * |
|
398 | - * @param string $offset |
|
399 | - * |
|
400 | - * @return mixed |
|
401 | - */ |
|
402 | - public function offsetGet($offset) |
|
403 | - { |
|
404 | - return $this->data[$offset]; |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Assigns a value to the specified offset |
|
409 | - * |
|
410 | - * @param string $offset |
|
411 | - * @param mixed $value |
|
412 | - * |
|
413 | - * @return void |
|
414 | - */ |
|
415 | - public function offsetSet($offset, $value): void |
|
416 | - { |
|
417 | - $this->assign($offset, $value); |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * Unsets an offset. |
|
422 | - * |
|
423 | - * @param string $offset |
|
424 | - * |
|
425 | - * @return void |
|
426 | - */ |
|
427 | - public function offsetUnset($offset): void |
|
428 | - { |
|
429 | - unset($this->data[$offset]); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Magic method. |
|
434 | - * |
|
435 | - * Searches for the given variable and returns its value. |
|
436 | - * Local variables will be returned before global variables. |
|
437 | - * |
|
438 | - * @example $value = $view->var; |
|
439 | - * |
|
440 | - * @param string $key Variable name |
|
441 | - * |
|
442 | - * @return mixed |
|
443 | - * |
|
444 | - * @throws \Syscodes\Components\LenevorException |
|
445 | - */ |
|
446 | - public function &__get($key) |
|
447 | - { |
|
448 | - return $this->get($key); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Magic method. |
|
453 | - * |
|
454 | - * Calls [$this->set] with the same parameters. |
|
455 | - * |
|
456 | - * @example $view->var = 'something'; |
|
457 | - * |
|
458 | - * @param string $key Variable name |
|
459 | - * @param mixed $value Value |
|
460 | - * |
|
461 | - * @return void |
|
462 | - */ |
|
463 | - public function __set($key, $value) |
|
464 | - { |
|
465 | - $this->set($key, $value); |
|
466 | - } |
|
467 | - |
|
468 | - /** |
|
469 | - * Magic method. |
|
470 | - * |
|
471 | - * Determines if a variable is set. |
|
472 | - * |
|
473 | - * @example isset($view->foo); |
|
474 | - * |
|
475 | - * Variables are not considered to be set. |
|
476 | - * |
|
477 | - * @param string $key variable name |
|
478 | - * |
|
479 | - * @return boolean |
|
480 | - */ |
|
481 | - public function __isset($key) |
|
482 | - { |
|
483 | - return isset($this->data[$key]); |
|
484 | - } |
|
485 | - |
|
486 | - /** |
|
487 | - * Magic method. |
|
488 | - * |
|
489 | - * Unsets a given variable. |
|
490 | - * |
|
491 | - * @example unset($view->var); |
|
492 | - * |
|
493 | - * @param string $key Variable name |
|
494 | - * |
|
495 | - * @return void |
|
496 | - */ |
|
497 | - public function __unset($key) |
|
498 | - { |
|
499 | - unset($this->data[$key]); |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Magic Method for handling dynamic functions. |
|
504 | - * |
|
505 | - * @param string $method |
|
506 | - * @param array $parameters |
|
507 | - * |
|
508 | - * @return mixed |
|
509 | - * |
|
510 | - * @throws \BadMethodCallException |
|
511 | - */ |
|
512 | - public function __call($method, $parameters) |
|
513 | - { |
|
514 | - if (static::hasMacro($method)) { |
|
515 | - return $this->macroCall($method, $parameters); |
|
516 | - } |
|
517 | - |
|
518 | - if (Str::startsWith($method, 'assign')) { |
|
519 | - $name = Str::camelcase(substr($method, 4)); |
|
520 | - |
|
521 | - return $this->assign($name, $parameters[0]); |
|
522 | - } |
|
523 | - |
|
524 | - throw new BadMethodCallException(sprintf( |
|
525 | - 'Method %s::%s() does not exist', static::class, $method) |
|
526 | - ); |
|
527 | - } |
|
528 | - |
|
529 | - /** |
|
530 | - * Get content as a string of HTML. |
|
531 | - * |
|
532 | - * @return string |
|
533 | - */ |
|
534 | - public function toHtml(): string |
|
535 | - { |
|
536 | - return $this->render(); |
|
537 | - } |
|
538 | - |
|
539 | - /** |
|
540 | - * Magic method. |
|
541 | - * |
|
542 | - * Returns the output of [static::render]. |
|
543 | - * |
|
544 | - * @return string |
|
545 | - * |
|
546 | - * @throws \Throwable |
|
547 | - */ |
|
548 | - public function __toString(): string |
|
549 | - { |
|
550 | - return $this->render(); |
|
551 | - } |
|
383 | + /** |
|
384 | + * Whether or not an offset exists. |
|
385 | + * |
|
386 | + * @param string $offset |
|
387 | + * |
|
388 | + * @return bool |
|
389 | + */ |
|
390 | + public function offsetExists($offset): bool |
|
391 | + { |
|
392 | + return array_key_exists($offset, $this->data); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Returns the value at specified offset. |
|
397 | + * |
|
398 | + * @param string $offset |
|
399 | + * |
|
400 | + * @return mixed |
|
401 | + */ |
|
402 | + public function offsetGet($offset) |
|
403 | + { |
|
404 | + return $this->data[$offset]; |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Assigns a value to the specified offset |
|
409 | + * |
|
410 | + * @param string $offset |
|
411 | + * @param mixed $value |
|
412 | + * |
|
413 | + * @return void |
|
414 | + */ |
|
415 | + public function offsetSet($offset, $value): void |
|
416 | + { |
|
417 | + $this->assign($offset, $value); |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * Unsets an offset. |
|
422 | + * |
|
423 | + * @param string $offset |
|
424 | + * |
|
425 | + * @return void |
|
426 | + */ |
|
427 | + public function offsetUnset($offset): void |
|
428 | + { |
|
429 | + unset($this->data[$offset]); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Magic method. |
|
434 | + * |
|
435 | + * Searches for the given variable and returns its value. |
|
436 | + * Local variables will be returned before global variables. |
|
437 | + * |
|
438 | + * @example $value = $view->var; |
|
439 | + * |
|
440 | + * @param string $key Variable name |
|
441 | + * |
|
442 | + * @return mixed |
|
443 | + * |
|
444 | + * @throws \Syscodes\Components\LenevorException |
|
445 | + */ |
|
446 | + public function &__get($key) |
|
447 | + { |
|
448 | + return $this->get($key); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Magic method. |
|
453 | + * |
|
454 | + * Calls [$this->set] with the same parameters. |
|
455 | + * |
|
456 | + * @example $view->var = 'something'; |
|
457 | + * |
|
458 | + * @param string $key Variable name |
|
459 | + * @param mixed $value Value |
|
460 | + * |
|
461 | + * @return void |
|
462 | + */ |
|
463 | + public function __set($key, $value) |
|
464 | + { |
|
465 | + $this->set($key, $value); |
|
466 | + } |
|
467 | + |
|
468 | + /** |
|
469 | + * Magic method. |
|
470 | + * |
|
471 | + * Determines if a variable is set. |
|
472 | + * |
|
473 | + * @example isset($view->foo); |
|
474 | + * |
|
475 | + * Variables are not considered to be set. |
|
476 | + * |
|
477 | + * @param string $key variable name |
|
478 | + * |
|
479 | + * @return boolean |
|
480 | + */ |
|
481 | + public function __isset($key) |
|
482 | + { |
|
483 | + return isset($this->data[$key]); |
|
484 | + } |
|
485 | + |
|
486 | + /** |
|
487 | + * Magic method. |
|
488 | + * |
|
489 | + * Unsets a given variable. |
|
490 | + * |
|
491 | + * @example unset($view->var); |
|
492 | + * |
|
493 | + * @param string $key Variable name |
|
494 | + * |
|
495 | + * @return void |
|
496 | + */ |
|
497 | + public function __unset($key) |
|
498 | + { |
|
499 | + unset($this->data[$key]); |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Magic Method for handling dynamic functions. |
|
504 | + * |
|
505 | + * @param string $method |
|
506 | + * @param array $parameters |
|
507 | + * |
|
508 | + * @return mixed |
|
509 | + * |
|
510 | + * @throws \BadMethodCallException |
|
511 | + */ |
|
512 | + public function __call($method, $parameters) |
|
513 | + { |
|
514 | + if (static::hasMacro($method)) { |
|
515 | + return $this->macroCall($method, $parameters); |
|
516 | + } |
|
517 | + |
|
518 | + if (Str::startsWith($method, 'assign')) { |
|
519 | + $name = Str::camelcase(substr($method, 4)); |
|
520 | + |
|
521 | + return $this->assign($name, $parameters[0]); |
|
522 | + } |
|
523 | + |
|
524 | + throw new BadMethodCallException(sprintf( |
|
525 | + 'Method %s::%s() does not exist', static::class, $method) |
|
526 | + ); |
|
527 | + } |
|
528 | + |
|
529 | + /** |
|
530 | + * Get content as a string of HTML. |
|
531 | + * |
|
532 | + * @return string |
|
533 | + */ |
|
534 | + public function toHtml(): string |
|
535 | + { |
|
536 | + return $this->render(); |
|
537 | + } |
|
538 | + |
|
539 | + /** |
|
540 | + * Magic method. |
|
541 | + * |
|
542 | + * Returns the output of [static::render]. |
|
543 | + * |
|
544 | + * @return string |
|
545 | + * |
|
546 | + * @throws \Throwable |
|
547 | + */ |
|
548 | + public function __toString(): string |
|
549 | + { |
|
550 | + return $this->render(); |
|
551 | + } |
|
552 | 552 | } |
553 | 553 | \ No newline at end of file |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->factory->flushStateIfDoneRendering(); |
131 | 131 | |
132 | 132 | return ! is_null($response) ? $response : $contents; |
133 | - } catch(Throwable $e) { |
|
133 | + } catch (Throwable $e) { |
|
134 | 134 | $this->factory->flushState(); |
135 | 135 | |
136 | 136 | throw $e; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function bind($key, & $value): static |
224 | 224 | { |
225 | - $this->data[$key] =& $value; |
|
225 | + $this->data[$key] = & $value; |
|
226 | 226 | |
227 | 227 | return $this; |
228 | 228 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * |
58 | 58 | * @return int|string |
59 | 59 | */ |
60 | - protected function algorithm(): int|string |
|
60 | + protected function algorithm(): int | string |
|
61 | 61 | { |
62 | 62 | return PASSWORD_ARGON2ID; |
63 | 63 | } |
@@ -129,7 +129,7 @@ |
||
129 | 129 | 'memory_cost' => $this->memory($options), |
130 | 130 | 'time_cost' => $this->time($options), |
131 | 131 | 'threads' => $this->threads($options), |
132 | - ]); |
|
132 | + ]); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * |
180 | 180 | * @return int|string |
181 | 181 | */ |
182 | - protected function algorithm(): int|string |
|
182 | + protected function algorithm(): int | string |
|
183 | 183 | { |
184 | 184 | return PASSWORD_ARGON2I; |
185 | 185 | } |