Completed
Push — master ( c1a6aa...6b2a43 )
by WEBEWEB
01:44
created

DefaultNavigationThemeProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getTree() 0 3 1
A getView() 0 3 1
A translate() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Theme;
13
14
use WBW\Bundle\CoreBundle\Navigation\NavigationTree;
15
use WBW\Bundle\CoreBundle\Provider\Theme\NavigationThemeProviderInterface;
16
use WBW\Bundle\CoreBundle\Service\TranslatorTrait;
17
18
/**
19
 * Default navigation theme provider.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\CoreBundle\Theme
23
 */
24
class DefaultNavigationThemeProvider implements NavigationThemeProviderInterface {
25
26
    use TranslatorTrait {
27
        setTranslator as public;
28
    }
29
30
    /**
31
     * Constructor.
32
     */
33
    public function __construct() {
34
        // NOTHING TO DO.
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function getTree() {
41
        return new NavigationTree("");
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function getView() {
48
        return null;
49
    }
50
51
    /**
52
     * Translate.
53
     *
54
     * @param string $id The id.
55
     * @param array $parameters Teh parameters.
56
     * @param string $domain The domain.
57
     * @param string $locale The locale.
58
     * @return string Returns the translated id in case of success, id otherwise.
59
     */
60
    protected function translate($id, array $parameters = [], $domain = null, $locale = null) {
61
62
        if (null === $this->getTranslator()) {
63
            return $id;
64
        }
65
66
        return $this->getTranslator()->trans($id, $parameters, $domain, $locale);
67
    }
68
}
69