Completed
Push — master ( a2b9d1...d3fba9 )
by WEBEWEB
01:53
created

AbstractPreloaderTwigExtension::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the adminbsb-material-design-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\AdminBSBBundle\Twig\Extension\UI;
13
14
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractTwigExtension;
15
16
/**
17
 * Abstract preloader Twig extension.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
21
 * @abstract
22
 */
23
abstract class AbstractPreloaderTwigExtension extends AbstractTwigExtension {
24
25
    /**
26
     * Displays an AdminBSB preloader.
27
     *
28
     * @param string $class The class.
29
     * @param string $size The size.
30
     * @return string Returns the AdminBSB preloader.
31
     */
32
    protected function adminBSBPreloader($class, $size) {
33
34
        $sizes = ["xs", "sm", "l", "xl"];
35
36
        $attributes = [];
37
38
        $attributes["class"][] = "preloader";
39
        $attributes["class"][] = true === in_array($size, $sizes) ? "pl-size-" . $size : null;
40
41
        $content   = "<div class=\"circle-clipper left\"><div class=\"circle\"></div></div><div class=\"circle-clipper right\"><div class=\"circle\"></div></div>";
42
        $innerHTML = static::coreHTMLElement("div", $content, ["class" => ["spinner-layer", $class]]);
43
44
        return static::coreHTMLElement("div", $innerHTML, $attributes);
45
    }
46
}
47