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

HandlebarsHelperService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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 @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