CmsHelper::handle()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.7666
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 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