Conditions | 2 |
Paths | 1 |
Total Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 23 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
10 | 24 | public function register(Plates\Engine $plates) { |
|
11 | 24 | $c = $plates->getContainer(); |
|
12 | |||
13 | 24 | $c->wrap('renderTemplate.factories', function($factories, $c) { |
|
14 | 24 | $default_layout_path = $c->get('config')['default_layout_path']; |
|
15 | 24 | if ($default_layout_path) { |
|
16 | 12 | $factories[] = DefaultLayoutRenderTemplate::factory($default_layout_path); |
|
17 | } |
||
18 | 24 | $factories[] = LayoutRenderTemplate::factory(); |
|
19 | 24 | return $factories; |
|
20 | 24 | }); |
|
21 | |||
22 | 24 | $plates->defineConfig(['default_layout_path' => null]); |
|
|
|||
23 | 24 | $plates->pushComposers(function($c) { |
|
24 | 24 | return ['layoutSections.sections' => sectionsCompose()]; |
|
25 | 24 | }); |
|
26 | 24 | $plates->addFuncs(function($c) { |
|
27 | 24 | $template_args = RenderContext\assertTemplateArgsFunc(); |
|
28 | 24 | $one_arg = RenderContext\assertArgsFunc(1); |
|
29 | |||
30 | return [ |
||
31 | 24 | 'layout' => [layoutFunc(), $template_args], |
|
32 | 24 | 'section' => [sectionFunc(), RenderContext\assertArgsFunc(1, 1)], |
|
33 | 24 | 'start' => [startFunc(), $one_arg], |
|
34 | 24 | 'push' => [startFunc(START_APPEND), $one_arg], |
|
35 | 24 | 'unshift' => [startFunc(START_PREPEND), $one_arg], |
|
36 | ]; |
||
37 | 24 | }); |
|
38 | 24 | } |
|
39 | } |
||
40 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: