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

BadgeRenderer::renderContent()   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\Badge;
13
14
/**
15
 * Badge renderer.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Bundle\BootstrapBundle\Badge
19
 */
20
class BadgeRenderer {
21
22
    /**
23
     * Render a content.
24
     *
25
     * @param BadgeInterface $badge The badge.
26
     * @return string Returns the rendered block.
27
     */
28
    public static function renderContent(BadgeInterface $badge) {
29
        return null !== $badge->getContent() ? $badge->getContent() : "";
30
    }
31
32
    /**
33
     * Render a pill.
34
     *
35
     * @param BadgeInterface $badge The badge.
36
     * @return string|null Returns the rendered pill.
37
     */
38
    public static function renderPill(BadgeInterface $badge) {
39
        return true === $badge->getPill() ? "badge-pill" : null;
40
    }
41
42
    /**
43
     * Render a type.
44
     *
45
     * @param BadgeInterface $badge The badge.
46
     * @return string|null Returns the rendered type.
47
     */
48
    public static function renderType(BadgeInterface $badge) {
49
        return null !== $badge->getType() ? $badge->getPrefix() . $badge->getType() : null;
50
    }
51
}
52