Completed
Push — master ( a27d66...168bdb )
by WEBEWEB
05:24
created

ButtonFactory::newDarkButton()   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\Button;
13
14
use WBW\Library\Core\Argument\ArrayHelper;
15
16
/**
17
 * Button factory.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\Button
21
 */
22
class ButtonFactory {
23
24
    /**
25
     * Creates a new danger button.
26
     *
27
     * @return ButtonInterface Returns the danger button.
28
     */
29
    public static function newDangerButton() {
30
        return new DangerButton();
31
    }
32
33
    /**
34
     * Creates a new dark button.
35
     *
36
     * @return ButtonInterface Returns the dark button.
37
     */
38
    public static function newDarkButton() {
39
        return new DarkButton();
40
    }
41
42
    /**
43
     * Creates a new default button.
44
     *
45
     * @return ButtonInterface Returns the default button.
46
     */
47
    public static function newDefaultButton() {
48
        return new DefaultButton();
49
    }
50
51
    /**
52
     * Creates a new info button.
53
     *
54
     * @return ButtonInterface Returns the info button.
55
     */
56
    public static function newInfoButton() {
57
        return new InfoButton();
58
    }
59
60
    /**
61
     * Creates a new light button.
62
     *
63
     * @return ButtonInterface Returns the light button.
64
     */
65
    public static function newLightButton() {
66
        return new LightButton();
67
    }
68
69
    /**
70
     * Creates a new link button.
71
     *
72
     * @return ButtonInterface Returns the link button.
73
     */
74
    public static function newLinkButton() {
75
        return new LinkButton();
76
    }
77
78
    /**
79
     * Creates a new primary button.
80
     *
81
     * @return ButtonInterface Returns the primary button.
82
     */
83
    public static function newPrimaryButton() {
84
        return new PrimaryButton();
85
    }
86
87
    /**
88
     * Creates a new secondary button.
89
     *
90
     * @return ButtonInterface Returns the secondary button.
91
     */
92
    public static function newSecondaryButton() {
93
        return new SecondaryButton();
94
    }
95
96
    /**
97
     * Creates a new success button.
98
     *
99
     * @return ButtonInterface Returns the success button.
100
     */
101
    public static function newSuccessButton() {
102
        return new SuccessButton();
103
    }
104
105
    /**
106
     * Creates a new warning button.
107
     *
108
     * @return ButtonInterface Returns the warning button.
109
     */
110
    public static function newWarningButton() {
111
        return new WarningButton();
112
    }
113
114
    /**
115
     * Parses a button.
116
     *
117
     * @param ButtonInterface $button The button.
118
     * @param array $args The arguments.
119
     * @return ButtonInterface Returns the button.
120
     */
121
    protected static function parseButton(ButtonInterface $button, array $args) {
122
123
        $button->setActive(ArrayHelper::get($args, "active", false));
124
        $button->setBlock(ArrayHelper::get($args, "block", false));
125
        $button->setContent(ArrayHelper::get($args, "content"));
126
        $button->setDisabled(ArrayHelper::get($args, "disabled", false));
127
        $button->setOutline(ArrayHelper::get($args, "outline", false));
128
        $button->setSize(ArrayHelper::get($args, "size"));
129
        $button->setTitle(ArrayHelper::get($args, "title"));
130
131
        return $button;
132
    }
133
134
    /**
135
     * Parse a danger button.
136
     *
137
     * @param array $args The arguments.
138
     * @return ButtonInterface Returns the danger button.
139
     */
140
    public static function parseDangerButton(array $args) {
141
        return static::parseButton(static::newDangerButton(), $args);
142
    }
143
144
    /**
145
     * Parse a dark button.
146
     *
147
     * @param array $args The arguments.
148
     * @return ButtonInterface Returns the dark button.
149
     */
150
    public static function parseDarkButton(array $args) {
151
        return static::parseButton(static::newDarkButton(), $args);
152
    }
153
154
    /**
155
     * Parse a default button.
156
     *
157
     * @param array $args The arguments.
158
     * @return ButtonInterface Returns the default button.
159
     */
160
    public static function parseDefaultButton(array $args) {
161
        return static::parseButton(static::newDefaultButton(), $args);
162
    }
163
164
    /**
165
     * Parse a info button.
166
     *
167
     * @param array $args The arguments.
168
     * @return ButtonInterface Returns the info button.
169
     */
170
    public static function parseInfoButton(array $args) {
171
        return static::parseButton(static::newInfoButton(), $args);
172
    }
173
174
    /**
175
     * Parse a light button.
176
     *
177
     * @param array $args The arguments.
178
     * @return ButtonInterface Returns the light button.
179
     */
180
    public static function parseLightButton(array $args) {
181
        return static::parseButton(static::newLightButton(), $args);
182
    }
183
184
    /**
185
     * Parse a link button.
186
     *
187
     * @param array $args The arguments.
188
     * @return ButtonInterface Returns the link button.
189
     */
190
    public static function parseLinkButton(array $args) {
191
        return static::parseButton(static::newLinkButton(), $args);
192
    }
193
194
    /**
195
     * Parse a primary button.
196
     *
197
     * @param array $args The arguments.
198
     * @return ButtonInterface Returns the primary button.
199
     */
200
    public static function parsePrimaryButton(array $args) {
201
        return static::parseButton(static::newPrimaryButton(), $args);
202
    }
203
204
    /**
205
     * Parse a secondary button.
206
     *
207
     * @param array $args The arguments.
208
     * @return ButtonInterface Returns the secondary button.
209
     */
210
    public static function parseSecondaryButton(array $args) {
211
        return static::parseButton(static::newSecondaryButton(), $args);
212
    }
213
214
    /**
215
     * Parse a success button.
216
     *
217
     * @param array $args The arguments.
218
     * @return ButtonInterface Returns the success button.
219
     */
220
    public static function parseSuccessButton(array $args) {
221
        return static::parseButton(static::newSuccessButton(), $args);
222
    }
223
224
    /**
225
     * Parse a warning button.
226
     *
227
     * @param array $args The arguments.
228
     * @return ButtonInterface Returns the warning button.
229
     */
230
    public static function parseWarningButton(array $args) {
231
        return static::parseButton(static::newWarningButton(), $args);
232
    }
233
}
234