Conditions | 3 |
Paths | 1 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Tests | 25 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
9 | 24 | public function register(Plates\Engine $plates) { |
|
10 | 24 | $c = $plates->getContainer(); |
|
11 | 24 | $c->add('path.resolvePath.prefixes', function($c) { |
|
12 | 24 | return (array) ($c->get('config')['base_dir'] ?? []); |
|
13 | 24 | }); |
|
14 | 24 | $c->addComposed('path.normalizeName', function($c) { |
|
15 | return [ |
||
16 | 24 | 'path.stripExt' => stripExtNormalizeName(), |
|
17 | 24 | 'path.stripPrefix' => stripPrefixNormalizeName($c->get('path.resolvePath.prefixes')) |
|
18 | ]; |
||
19 | 24 | }); |
|
20 | 24 | $c->addStack('path.resolvePath', function($c) { |
|
21 | 24 | $config = $c->get('config'); |
|
22 | 24 | $prefixes = $c->get('path.resolvePath.prefixes'); |
|
23 | 24 | return array_filter([ |
|
24 | 24 | 'path.id' => idResolvePath(), |
|
25 | 24 | 'path.prefix' => $prefixes ? prefixResolvePath($prefixes, $c->get('fileExists')) : null, |
|
26 | 24 | 'path.ext' => isset($config['ext']) ? extResolvePath($config['ext']) : null, |
|
27 | 24 | 'path.relative' => relativeResolvePath(), |
|
28 | ]); |
||
29 | 24 | }); |
|
30 | 24 | $plates->defineConfig([ |
|
|
|||
31 | 24 | 'ext' => 'phtml', |
|
32 | 'base_dir' => null, |
||
33 | ]); |
||
34 | 24 | $plates->pushComposers(function($c) { |
|
35 | return [ |
||
36 | 24 | 'path.normalizeName' => normalizeNameCompose($c->get('path.normalizeName')), |
|
37 | 24 | 'path.resolvePath' => resolvePathCompose($c->get('path.resolvePath')), |
|
38 | ]; |
||
39 | 24 | }); |
|
40 | 24 | } |
|
41 | } |
||
42 |
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: