HandlebarsHelperService::getHelpers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[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 3
            $this->helpers[$id] = [$helper, 'handle'];
22 2
        } elseif (is_callable($helper)) {
23 2
            $this->helpers[$id] = $helper;
24
        }
25 5
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 4
    public function getHelperMethods()
31
    {
32 4
        return array_keys($this->helpers);
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 5
    public function getHelpers()
39
    {
40 5
        return $this->helpers;
41
    }
42
}
43