Completed
Push — master ( 4a40ab...6b6d29 )
by WEBEWEB
01:42
created

materialDesignIconicFontList()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\Twig\Extension\Plugin;
13
14
use Twig_Environment;
15
use WBW\Bundle\CoreBundle\Icon\MaterialDesignIconicFontIconInterface;
16
use WBW\Bundle\CoreBundle\Icon\MaterialDesignIconicFontIconRenderer;
17
use WBW\Bundle\CoreBundle\Twig\Extension\AbstractTwigExtension;
18
use WBW\Library\Core\Argument\StringHelper;
19
20
/**
21
 * Abstract Material Design Iconic Font Twig extension.
22
 *
23
 * @author webeweb <https://github.com/webeweb/>
24
 * @package WBW\Bundle\Core\Twig\Extension\Plugin
25
 * @abstract
26
 */
27
abstract class AbstractMaterialDesignIconicFontTwigExtension extends AbstractTwigExtension {
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param Twig_Environment $twigEnvironment The twig environment.
33
     */
34
    protected function __construct(Twig_Environment $twigEnvironment) {
35
        parent::__construct($twigEnvironment);
36
    }
37
38
    /**
39
     * Displays a Material Design Iconic Font icon.
40
     *
41
     * @param MaterialDesignIconicFontIconInterface $icon The icon.
42
     * @return string Returns the Material Design Iconic Font icon.
43
     */
44
    protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon) {
45
46
        // Initialize the values.
47
        $sizes   = ["lg", "2x", "3x", "4x", "5x"];
0 ignored issues
show
Unused Code introduced by
$sizes is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
48
        $borders = ["border", "border-circle"];
0 ignored issues
show
Unused Code introduced by
$borders is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
49
        $pulls   = ["left", "right"];
0 ignored issues
show
Unused Code introduced by
$pulls is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
        $spins   = ["spin", "spin-reverse"];
0 ignored issues
show
Unused Code introduced by
$spins is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
51
        $rotates = ["90", "180", "270"];
0 ignored issues
show
Unused Code introduced by
$rotates is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
        $flips   = ["horizontal", "vertical"];
0 ignored issues
show
Unused Code introduced by
$flips is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
53
54
        // Initialize the attributes.
55
        $attributes = [];
56
57
        $attributes["class"][] = "zmdi";
58
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
59
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSize($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
60
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
61
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderBorder($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
62
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderPull($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
63
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSpin($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
64
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderRotate($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
65
        $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFlip($icon);
0 ignored issues
show
Compatibility introduced by
$icon of type object<WBW\Bundle\CoreBu...conicFontIconInterface> is not a sub-type of object<WBW\Bundle\CoreBu...alDesignIconicFontIcon>. It seems like you assume a concrete implementation of the interface WBW\Bundle\CoreBundle\Ic...IconicFontIconInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
66
        $attributes["style"]   = MaterialDesignIconicFontIconRenderer::renderStyle($icon);
67
68
        // Return the HTML.
69
        return static::coreHTMLElement("i", null, $attributes);
70
    }
71
72
    /**
73
     * Displays a Material Design Iconic Font list.
74
     *
75
     * @param array|string $items The items.
76
     * @return string Returns the Material Design Iconic Font list.
77
     */
78
    protected function materialDesignIconicFontList($items) {
79
80
        // Initialize the parameters.
81
        $innerHTML = true === is_array($items) ? implode("\n", $items) : $items;
82
83
        // Return the HTML.
84
        return static::coreHTMLElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]);
85
    }
86
87
    /**
88
     * Displays a Material Design Iconic Font list icon.
89
     *
90
     * @param string $icon The icon.
91
     * @param string $content The content.
92
     * @return string Returns the Material Design Iconic Font list icon.
93
     */
94
    protected function materialDesignIconicFontListIcon($icon, $content) {
95
96
        // Initialize the parameters.
97
        $glyphicon = null !== $icon ? StringHelper::replace($icon, ["class=\"zmdi"], ["class=\"zmdi-hc-li zmdi"]) : "";
98
        $innerHTML = null !== $content ? $content : "";
99
100
        // Return the HTML.
101
        return static::coreHTMLElement("li", $glyphicon . $innerHTML);
102
    }
103
104
}
105