GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Alert   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 11
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 66
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A info() 0 4 1
A danger() 0 4 1
A error() 0 4 1
A success() 0 4 1
A warning() 0 4 1
A render() 0 10 2
A setDismissible() 0 10 2
A __invoke() 0 8 2
1
<?php
2
3
/**
4
 * Alert view helper styled for Bootstrap 3.
5
 *
6
 * @author     Leandro Silva <[email protected]>
7
 *
8
 * @category   LosUi
9
 *
10
 * @license    https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License
11
 *
12
 * @link       http://github.com/LansoWeb/LosUi
13
 * @link       http://getbootstrap.com/components/#alerts
14
 */
15
namespace LosUi\View\Helper;
16
17
/**
18
 * Alert view helper styled for Bootstrap 3.
19
 *
20
 * @author     Leandro Silva <[email protected]>
21
 *
22
 * @category   LosUi
23
 *
24
 * @license    https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License
25
 *
26
 * @link       http://github.com/LansoWeb/LosUi
27
 * @link       http://getbootstrap.com/components/#alerts
28
 */
29
class Alert
30
{
31
    protected $format = '<div class="alert %s" role="alert">%s</div>';
32
33
    protected $formatDismissible = '<div class="alert alert-dismissible %s" role="alert"><button type="button" '.
34
        'class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>'.
35
        '</button>%s</div>';
36
37
    protected $isDismissible = false;
38
39
    public function info($alert)
40
    {
41
        return $this->render($alert, 'alert-info');
42
    }
43
44
    public function danger($alert)
45
    {
46
        return $this->render($alert, 'alert-danger');
47
    }
48
49
    public function error($alert)
50
    {
51
        return $this->danger($alert);
52
    }
53
54
    public function success($alert)
55
    {
56
        return $this->render($alert, 'alert-success');
57
    }
58
59
    public function warning($alert)
60
    {
61
        return $this->render($alert, 'alert-warning');
62
    }
63
64
    public function render($alert, $class = 'alert-warning')
65
    {
66
        $class = trim($class);
67
68
        if ($this->isDismissible) {
69
            return sprintf($this->formatDismissible, $class, $alert);
70
        } else {
71
            return sprintf($this->format, $class, $alert);
72
        }
73
    }
74
75
    public function setDismissible($dismissible)
76
    {
77
        if (! is_bool($dismissible)) {
78
            throw new \InvalidArgumentException('Argument must be a bool value.');
79
        }
80
81
        $this->isDismissible = $dismissible;
82
83
        return $this;
84
    }
85
86
    public function __invoke($alert = null, $class = 'alert-warning')
87
    {
88
        if ($alert) {
89
            return $this->render($alert, $class);
90
        }
91
92
        return $this;
93
    }
94
}
95