Completed
Push — master ( 46b523...907816 )
by WEBEWEB
01:22
created

AbstractAdminBSBTwigExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fixColor() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2017 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\AdminBSBBundle\Twig\Extension;
13
14
use Twig_Extension;
15
use WBW\Bundle\AdminBSBBundle\Provider\Color\DefaultColorProvider;
16
17
/**
18
 * Abstract AdminBSB Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension
22
 * @abstract
23
 */
24
abstract class AbstractAdminBSBTwigExtension extends Twig_Extension {
25
26
    /**
27
     * Default content.
28
     *
29
     * @var string
30
     */
31
    const DEFAULT_CONTENT = "&nbsp;";
32
33
    /**
34
     * Constructor.
35
     */
36
    protected function __construct() {
37
        // NOTHING TO DO.
38
    }
39
40
    /**
41
     * Fix a color.
42
     *
43
     * @param string $name The color name.
44
     * @param string $prefix The color prefix.
45
     * @return string Returns the prefix color in case of success, default color otherwise.
46
     */
47
    public static function fixColor($name, $prefix = "") {
48
        if (false === array_key_exists($name, DefaultColorProvider::getColors())) {
49
            $name = "red";
50
        }
51
        return $prefix . $name;
52
    }
53
54
}
55