Conditions | 3 |
Paths | 1 |
Total Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Tests | 26 |
CRAP Score | 3.0004 |
Changes | 0 |
1 | <?php |
||
9 | 24 | public function register(Plates\Engine $plates) { |
|
10 | 24 | $c = $plates->getContainer(); |
|
11 | 24 | $c->add('folders.folders', []); |
|
12 | 24 | $c->wrapStack('path.resolvePath', function($stack, $c) { |
|
13 | 24 | $config = $c; |
|
14 | 24 | return array_merge($stack, [ |
|
15 | 24 | 'folders' => foldersResolvePath( |
|
16 | 24 | $c->get('folders.folders'), |
|
17 | 24 | $c->get('config')['folder_separator'], |
|
18 | 24 | $c->get('fileExists') |
|
19 | ) |
||
20 | ]); |
||
21 | 24 | }); |
|
22 | 24 | $c->wrapComposed('path.normalizeName', function($composed, $c) { |
|
23 | 24 | return array_merge($composed, [ |
|
24 | 24 | 'folders.stripFolders' => stripFoldersNormalizeName($c->get('folders.folders')) |
|
25 | ]); |
||
26 | 24 | }); |
|
27 | |||
28 | 24 | $plates->defineConfig([ |
|
|
|||
29 | 24 | 'folder_separator' => '::', |
|
30 | ]); |
||
31 | 24 | $plates->addMethods([ |
|
32 | 24 | 'addFolder' => function($plates, $folder, $prefixes, $fallback = false) { |
|
33 | 4 | $prefixes = is_string($prefixes) ? [$prefixes] : $prefixes; |
|
34 | 4 | if ($fallback) { |
|
35 | $prefixes[] = ''; |
||
36 | } |
||
37 | 4 | $plates->getContainer()->merge('folders.folders', [ |
|
38 | $folder => [ |
||
39 | 4 | 'folder' => $folder, |
|
40 | 4 | 'prefixes' => $prefixes, |
|
41 | ] |
||
42 | ]); |
||
43 | 24 | }, |
|
44 | ]); |
||
45 | 24 | } |
|
46 | } |
||
47 |
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: