Completed
Push — master ( 4bad7d...520f7c )
by WEBEWEB
01:43
created

ButtonRenderer::renderSize()   A

Complexity

Conditions 2
Paths 2

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 2
nc 2
nop 1
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
/**
15
 * Button renderer.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Bundle\BootstrapBundle\Button
19
 */
20
class ButtonRenderer {
21
22
    /**
23
     * Render an active.
24
     *
25
     * @param ButtonInterface $button The button.
26
     * @return string|null Returns the rendered active.
27
     */
28
    public static function renderActive(ButtonInterface $button) {
29
        return true === $button->getActive() ? "active" : null;
30
    }
31
32
    /**
33
     * Render a block.
34
     *
35
     * @param ButtonInterface $button The button.
36
     * @return string|null Returns the rendered block.
37
     */
38
    public static function renderBlock(ButtonInterface $button) {
39
        return true !== $button->getBlock() ? "btn-block" : null;
40
    }
41
42
    /**
43
     * Render a data placement.
44
     *
45
     * @param ButtonInterface $button The button.
46
     * @return string|null Returns the rendered data placement.
47
     */
48
    public static function renderDataPlacement(ButtonInterface $button) {
49
        return null !== $button->getTitle() ? "top" : null;
50
    }
51
52
    /**
53
     * Render a data toggle.
54
     *
55
     * @param ButtonInterface $button The button.
56
     * @return string|null Returns the rendered data toggle.
57
     */
58
    public static function renderDataToggle(ButtonInterface $button) {
59
        return null !== $button->getTitle() ? "tooltip" : null;
60
    }
61
62
    /**
63
     * Render a disabled.
64
     *
65
     * @param ButtonInterface $button The button.
66
     * @return string|null Returns the rendered disabled.
67
     */
68
    public static function renderDisabled(ButtonInterface $button) {
69
        return true === $button->getDisabled() ? "disabled" : null;
70
    }
71
72
    /**
73
     * Render a size.
74
     *
75
     * @param ButtonInterface $button The button.
76
     * @return string|null Returns the rendered size.
77
     */
78
    public static function renderSize(ButtonInterface $button) {
79
        return null !== $button->getSize() ? "btn-" . $button->getSize() : null;
80
    }
81
82
    /**
83
     * Render a title.
84
     *
85
     * @param ButtonInterface $button The button.
86
     * @return string Returns the rendered title.
87
     */
88
    public static function renderTitle(ButtonInterface $button) {
89
        return $button->getTitle();
90
    }
91
}
92