Completed
Push — master ( 10f697...c17cc0 )
by WEBEWEB
02:43
created

AbstractColorTwigExtension::adminBSBColor()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 3
nc 4
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\AdminBSBBundle\Twig\Extension\UI;
13
14
use WBW\Bundle\AdminBSBBundle\Provider\Color\DefaultColorProvider;
15
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractAdminBSBTwigExtension;
16
17
/**
18
 * Abstract color Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
22
 * @abstract
23
 */
24
abstract class AbstractColorTwigExtension extends AbstractAdminBSBTwigExtension {
25
26
    /**
27
     * Constructor.
28
     */
29
    protected function __construct() {
30
        parent::__construct();
31
    }
32
33
    /**
34
     * Displays an AdminBSB color.
35
     *
36
     * @param string $name The color name.
37
     * @param string $code The color code.
38
     * @param string $output The output.
39
     * @return string Returns the AdminBSB color.
40
     */
41
    final protected function adminBSBColor($name, $code, $output) {
42
43
        // Initialize the parameters.
44
        $_name = self::fixColor($name, "");
45
        $_code = null !== $code ? $code : "500";
46
47
        // Return the HTML.
48
        return "hex" === $output ? DefaultColorProvider::getColors()[$_name][$_code] : "col-" . $_name;
49
    }
50
51
}
52