ButtonRenderer   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 18
lcom 0
cbo 1
dl 0
loc 93
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A renderActive() 0 3 2
A renderBlock() 0 3 2
A renderContent() 0 3 2
A renderDataPlacement() 0 3 2
A renderDataToggle() 0 3 2
A renderDisabled() 0 3 2
A renderSize() 0 3 2
A renderTitle() 0 3 1
A renderType() 0 4 3
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): ?string {
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): ?string {
39
        return true === $button->getBlock() ? "btn-block" : null;
40
    }
41
42
    /**
43
     * Render a content.
44
     *
45
     * @param ButtonInterface $button The button.
46
     * @return string Returns the rendered block.
47
     */
48
    public static function renderContent(ButtonInterface $button): ?string {
49
        return null !== $button->getContent() ? $button->getContent() : "";
50
    }
51
52
    /**
53
     * Render a data placement.
54
     *
55
     * @param ButtonInterface $button The button.
56
     * @return string|null Returns the rendered data placement.
57
     */
58
    public static function renderDataPlacement(ButtonInterface $button): ?string {
59
        return null !== $button->getTitle() ? "top" : null;
60
    }
61
62
    /**
63
     * Render a data toggle.
64
     *
65
     * @param ButtonInterface $button The button.
66
     * @return string|null Returns the rendered data toggle.
67
     */
68
    public static function renderDataToggle(ButtonInterface $button): ?string {
69
        return null !== $button->getTitle() ? "tooltip" : null;
70
    }
71
72
    /**
73
     * Render a disabled.
74
     *
75
     * @param ButtonInterface $button The button.
76
     * @return string|null Returns the rendered disabled.
77
     */
78
    public static function renderDisabled(ButtonInterface $button): ?string {
79
        return true === $button->getDisabled() ? "disabled" : null;
80
    }
81
82
    /**
83
     * Render a size.
84
     *
85
     * @param ButtonInterface $button The button.
86
     * @return string|null Returns the rendered size.
87
     */
88
    public static function renderSize(ButtonInterface $button): ?string {
89
        return null !== $button->getSize() ? "btn-" . $button->getSize() : null;
90
    }
91
92
    /**
93
     * Render a title.
94
     *
95
     * @param ButtonInterface $button The button.
96
     * @return string|null Returns the rendered title.
97
     */
98
    public static function renderTitle(ButtonInterface $button): ?string {
99
        return $button->getTitle();
100
    }
101
102
    /**
103
     * Render a type.
104
     *
105
     * @param ButtonInterface $button The button.
106
     * @return string|null Returns the rendered type.
107
     */
108
    public static function renderType(ButtonInterface $button): ?string {
109
        $prefix = $button->getPrefix() . (true === $button->getOutline() ? "outline-" : "");
110
        return null !== $button->getType() ? $prefix . $button->getType() : null;
111
    }
112
}
113