Passed
Branch master (e714e6)
by Gabriel
13:58 queued 11:36
created

HelpersExtension::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\View\Extensions\Helpers;
4
5
use Nip\View;
6
use Nip\View\Extensions\AbstractExtension;
7
use Nip\View\Helpers\HelpersCollection;
8
use Nip\View\Traits\HasMethodsTrait;
9
use Nip\View\Traits\MethodsOverloadingTrait;
10
use Nip\View\ViewInterface;
11
12
/**
13
 * Class HelpersExtension
14
 * @package Nip\View\Extensions\Helpers
15
 */
16
class HelpersExtension extends AbstractExtension
17
{
18
19
    /**
20
     * @param ViewInterface|MethodsOverloadingTrait|HasMethodsTrait|View $view
21
     * @return void
22
     */
23 6
    public function register(ViewInterface $view)
24
    {
25 6
        $view->getCallPipelineBuilder()->add(new HelpersPipelineStage());
0 ignored issues
show
Bug introduced by
The method getCallPipelineBuilder() does not exist on Nip\View\ViewInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Nip\View\ViewInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $view->/** @scrutinizer ignore-call */ 
26
               getCallPipelineBuilder()->add(new HelpersPipelineStage());
Loading history...
26 6
        HelpersCollection::getInstance()->setEngine($view);
27
28 6
        $view->addMethod('getHelper', function ($name) {
0 ignored issues
show
Bug introduced by
The method addMethod() does not exist on Nip\View\ViewInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Nip\View\ViewInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $view->/** @scrutinizer ignore-call */ 
29
               addMethod('getHelper', function ($name) {
Loading history...
29 1
            return HelpersCollection::getInstance()->getHelper($name);
30 6
        });
31
32 6
        $view->addMethod('hasHelper', function ($name) {
33 1
            return HelpersCollection::getInstance()->hasHelper($name);
34 6
        });
35 6
    }
36
}
37