Completed
Push — master ( f560d6...a27d66 )
by WEBEWEB
01:15
created

BadgeFactory::newDarkBadge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2019 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\BootstrapBundle\Badge;
13
14
use WBW\Library\Core\Argument\ArrayHelper;
15
16
/**
17
 * Badge factory.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\Badge
21
 */
22
class BadgeFactory {
23
24
    /**
25
     * Creates a new danger badge.
26
     *
27
     * @return BadgeInterface Returns the danger badge.
28
     */
29
    public static function newDangerBadge() {
30
        return new DangerBadge();
31
    }
32
33
    /**
34
     * Creates a new default badge.
35
     *
36
     * @return BadgeInterface Returns the default badge.
37
     */
38
    public static function newDarkBadge() {
39
        return new DarkBadge();
40
    }
41
42
    /**
43
     * Creates a new info badge.
44
     *
45
     * @return BadgeInterface Returns the info badge.
46
     */
47
    public static function newInfoBadge() {
48
        return new InfoBadge();
49
    }
50
51
    /**
52
     * Creates a new light badge.
53
     *
54
     * @return BadgeInterface Returns the light badge.
55
     */
56
    public static function newLightBadge() {
57
        return new LightBadge();
58
    }
59
60
    /**
61
     * Creates a new primary badge.
62
     *
63
     * @return BadgeInterface Returns the primary badge.
64
     */
65
    public static function newPrimaryBadge() {
66
        return new PrimaryBadge();
67
    }
68
69
    /**
70
     * Creates a new secondary badge.
71
     *
72
     * @return BadgeInterface Returns the secondary badge.
73
     */
74
    public static function newSecondaryBadge() {
75
        return new SecondaryBadge();
76
    }
77
78
    /**
79
     * Creates a new success badge.
80
     *
81
     * @return BadgeInterface Returns the success badge.
82
     */
83
    public static function newSuccessBadge() {
84
        return new SuccessBadge();
85
    }
86
87
    /**
88
     * Creates a new warning badge.
89
     *
90
     * @return BadgeInterface Returns the warning badge.
91
     */
92
    public static function newWarningBadge() {
93
        return new WarningBadge();
94
    }
95
96
    /**
97
     * Parses a badge.
98
     *
99
     * @param BadgeInterface $badge The badge.
100
     * @param array $args The arguments.
101
     * @return BadgeInterface Returns the badge.
102
     */
103
    protected static function parseBadge(BadgeInterface $badge, array $args) {
104
105
        $badge->setContent(ArrayHelper::get($args, "content"));
106
        $badge->setPill(ArrayHelper::get($args, "pill", false));
107
108
        return $badge;
109
    }
110
111
    /**
112
     * Parse a danger badge.
113
     *
114
     * @param array $args The arguments.
115
     * @return BadgeInterface Returns the danger badge.
116
     */
117
    public static function parseDangerBadge(array $args) {
118
        return static::parseBadge(static::newDangerBadge(), $args);
119
    }
120
121
    /**
122
     * Parse a dark badge.
123
     *
124
     * @param array $args The arguments.
125
     * @return BadgeInterface Returns the dark badge.
126
     */
127
    public static function parseDarkBadge(array $args) {
128
        return static::parseBadge(static::newDarkBadge(), $args);
129
    }
130
131
    /**
132
     * Parse a info badge.
133
     *
134
     * @param array $args The arguments.
135
     * @return BadgeInterface Returns the info badge.
136
     */
137
    public static function parseInfoBadge(array $args) {
138
        return static::parseBadge(static::newInfoBadge(), $args);
139
    }
140
141
    /**
142
     * Parse a light badge.
143
     *
144
     * @param array $args The arguments.
145
     * @return BadgeInterface Returns the light badge.
146
     */
147
    public static function parseLightBadge(array $args) {
148
        return static::parseBadge(static::newLightBadge(), $args);
149
    }
150
151
    /**
152
     * Parse a primary badge.
153
     *
154
     * @param array $args The arguments.
155
     * @return BadgeInterface Returns the primary badge.
156
     */
157
    public static function parsePrimaryBadge(array $args) {
158
        return static::parseBadge(static::newPrimaryBadge(), $args);
159
    }
160
161
    /**
162
     * Parse a secondary badge.
163
     *
164
     * @param array $args The arguments.
165
     * @return BadgeInterface Returns the secondary badge.
166
     */
167
    public static function parseSecondaryBadge(array $args) {
168
        return static::parseBadge(static::newSecondaryBadge(), $args);
169
    }
170
171
    /**
172
     * Parse a success badge.
173
     *
174
     * @param array $args The arguments.
175
     * @return BadgeInterface Returns the success badge.
176
     */
177
    public static function parseSuccessBadge(array $args) {
178
        return static::parseBadge(static::newSuccessBadge(), $args);
179
    }
180
181
    /**
182
     * Parse a warning badge.
183
     *
184
     * @param array $args The arguments.
185
     * @return BadgeInterface Returns the warning badge.
186
     */
187
    public static function parseWarningBadge(array $args) {
188
        return static::parseBadge(static::newWarningBadge(), $args);
189
    }
190
}
191