Completed
Push — master ( 7d5fc8...3fda6b )
by WEBEWEB
08:27
created

AbstractABSBMDTwigExtension::getArg()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 2
eloc 2
nc 2
nop 3
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\AdminBSBMaterialDesignBundle\Twig\Extension;
13
14
use Twig_Extension;
15
use WBW\Bundle\AdminBSBMaterialDesignBundle\Provider\Color\DefaultColorProvider;
16
17
/**
18
 * Abstract AdminBSB Material Design Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\AdminBSBMaterialDesignBundle\Twig\Extension
22
 * @abstract
23
 */
24
abstract class AbstractABSBMDTwigExtension 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
     * Get a color.
42
     *
43
     * @param string $name The color name.
44
     * @param string $prefix The color prefix.
45
     * @return string Returns the color in case of success, "" otherwise.
46
     */
47
    final protected function getColor($name, $prefix = "") {
48
        if (!array_key_exists($name, DefaultColorProvider::getColors())) {
49
            $name = "red";
50
        }
51
        return $prefix . $name;
52
    }
53
54
}
55