HandlebarsHelperService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addHelper() 0 8 3
A getHelperMethods() 0 4 1
A getHelpers() 0 4 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