Completed
Push — dev-master ( 3d2c20...b7e24f )
by Derek Stephen
08:18 queued 03:13
created

AlertBox   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 49
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B alertBox() 0 42 7
1
<?php
2
3
namespace Bone\View\Helper;
4
5
6
class AlertBox
7
{
8
    /**
9
     * @param $message
10
     * @return string
11
     */
12
    public static function alertBox($message): string
13
    {
14
        if (!$message) {
15
            return '';
16
        }
17
        
18
        if (!is_array($message)) {
19
            $text = $message;
20
            $message = array(
21
                'class' => 'warning',
22
                'message' => $text
23
            );
24
        }
25
        
26
        $alert = '<div class="alert ';
27
        if ($message['class'] != 'alert') {
28
            $alert .= 'alert-' . $message['class'];
29
        }
30
        
31
        $alert .= '"><button type="button" class="close" data-dismiss="alert" aria-label="Close">
32
                      <span aria-hidden="true">&times;</span>
33
                    </button>';
34
        
35
        if (!is_array($message['message'])) {
36
            $alert .= $message['message'];
37
            
38
        } else {
39
            $num = count($message['message']);
40
            $x = 1;
41
            foreach ($message['message'] as $message) {
42
                $alert .= $message;
43
                if ($x < $num) {
44
                    $alert .= '<br />';
45
                }
46
                $x++;
47
            }
48
        }
49
        
50
        $alert .= '</div>';
51
        
52
        return $alert;
53
    }
54
}