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

AlertRenderer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

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