CmsHelper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A handle() 0 15 3
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace JaySDe\HandlebarsBundle\Helper;
7
8
class CmsHelper implements HelperInterface
9
{
10
    private $defaultNamespace;
11
12
    /**
13
     * @var TranslationHelper
14
     */
15
    private $translationHelper;
16
17 5
    public function __construct(
18
        TranslationHelper $translationHelper,
19
        $defaultNamespace = null
20
    ) {
21 5
        $this->translationHelper = $translationHelper;
22 5
        $this->defaultNamespace = !is_null($defaultNamespace) ? $defaultNamespace . ':' : '';
23 5
    }
24
25 5
    public function handle($context, $options)
26
    {
27 5
        $options = isset($options['hash']) ? $options['hash'] : [];
28 5
        $bundle = $this->defaultNamespace;
29 5
        if (isset($options['bundle'])) {
30 2
            $bundle = $options['bundle'].':';
31 2
            unset($options['bundle']);
32
        }
33
34 5
        $cmsKey = $bundle.$context;
35
36 5
        $result = $this->translationHelper->handle($cmsKey, $options);
37
38 5
        return $result;
39
    }
40
}
41