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; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\AdminBSBBundle\Twig\Extension\UI\IconUITwigExtension; |
15
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\FactoryBootstrapTwigExtension; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Factory AdminBSB Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension |
22
|
|
|
*/ |
23
|
|
|
class FactoryAdminBSBTwigExtension extends AbstractAdminBSBTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Display an AdminBSB Material Design icon. |
27
|
|
|
* |
28
|
|
|
* @param string $name The icon name. |
29
|
|
|
* @param string $style The icon style. |
30
|
|
|
* @return string Returns the Admin BSB Materiel Design icon. |
31
|
|
|
*/ |
32
|
|
|
public static function adminBSBIcon($name, $style = null) { |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
// Determines the handler. |
36
|
|
|
$handler = explode(":", $name); |
37
|
|
|
|
38
|
|
|
// Get and check the parse count. |
39
|
|
|
$parseNb = count($handler); |
40
|
|
|
if ($parseNb < 1 || 2 < $parseNb) { |
41
|
|
|
return ""; |
42
|
|
|
} |
43
|
|
|
if (1 === count($handler)) { |
44
|
|
|
$handler = ["md", $name]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
// Initialize the output. |
48
|
|
|
$output = ""; |
|
|
|
|
49
|
|
|
|
50
|
|
|
// Swith into handler. |
51
|
|
|
switch ($handler[0]) { |
52
|
|
|
|
53
|
|
|
case "md": // Material Design |
54
|
|
|
$output = (new IconUITwigExtension())->adminBSBBasicIconFunction(["name" => $handler[1], "style" => $style]); |
55
|
|
|
break; |
56
|
|
|
|
57
|
|
|
default: |
58
|
|
|
$output = FactoryBootstrapTwigExtension::bootstrapIcon($name, $style); |
59
|
|
|
break; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// Return the output. |
63
|
|
|
return $output; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.