Completed
Push — develop ( e85978...1dc639 )
by Jens
05:42
created

HandlebarsHelperService::addHelper()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 2
crap 3
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
7
namespace JaySDe\HandlebarsBundle;
8
9
use JaySDe\HandlebarsBundle\Helper\HelperInterface;
10
11
class HandlebarsHelperService implements HandlebarsHelperServiceInterface
12
{
13
    private $helpers = [];
14
15
    /**
16
     * @inheritdoc
17
     */
18 5
    public function addHelper($id, $helper)
19
    {
20 5
        if ($helper instanceof HelperInterface) {
21 2
            $this->helpers[$id] = [$helper, 'handle'];
22 3
        } elseif (is_callable($helper)) {
23 2
            $this->helpers[$id] = $helper;
24
        }
25 5
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 1
    public function getHelperMethods()
31
    {
32 1
        return array_keys($this->helpers);
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 3
    public function getHelpers()
39
    {
40 3
        return $this->helpers;
41
    }
42
}
43