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.

Messages::render()   D
last analyzed

Complexity

Conditions 10
Paths 16

Size

Total Lines 28
Code Lines 15

Duplication

Lines 3
Ratio 10.71 %

Code Coverage

Tests 13
CRAP Score 10.2368

Importance

Changes 0
Metric Value
cc 10
eloc 15
nc 16
nop 3
dl 3
loc 28
ccs 13
cts 15
cp 0.8667
crap 10.2368
rs 4.8196
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Nip\Helpers\View;
4
5
class Messages extends AbstractHelper
6
{
7
8
    static $_cssClass = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $_cssClass.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
9
        'warning' => 'alert alert-warning',
10
        'error' => 'alert alert-danger',
11
        'success' => 'alert alert-success',
12
        'info' => 'alert alert-info',
13
    );
14
15 1
    public static function warning($items = array(), $wrap = true)
16
    {
17 1
        return self::render($items, 'warning', $wrap);
0 ignored issues
show
Documentation introduced by
'warning' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
18
    }
19
20 1
    public static function info($items = array(), $wrap = true)
21
    {
22 1
        return self::render($items, 'info', $wrap);
0 ignored issues
show
Documentation introduced by
'info' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
    }
24
25
    public static function success($items = array(), $wrap = true)
26
    {
27
        return self::render($items, 'success', $wrap);
0 ignored issues
show
Documentation introduced by
'success' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
    }
29
30
    public static function error($items = array(), $wrap = true)
31
    {
32
        return self::render($items, 'error', $wrap);
0 ignored issues
show
Documentation introduced by
'error' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
    }
34
35 2
    public static function render($items = array(), $type = false, $wrap = true)
36
    {
37 2
        $return = '';
38
39 2
        $items = (array)$items;
40
41 2
        if (count($items)) {
42 2
            if ($wrap) {
43 2
                $return .= '<div class="' . ($type ? self::$_cssClass[$type] : '') . '">';
44 2
                if (count($items) > 1) {
45
                    $return .= "<ul>";
46
                }
47
            }
48
49 2 View Code Duplication
            foreach ($items as $item) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50 2
                $return .= is_array($item) ? self::render($item, $type, false) : (count($items) > 1 ? "<li>$item</li>" : $item);
51
            }
52
53 2
            if ($wrap) {
54 2
                if (count($items) > 1) {
55
                    $return .= "</ul>";
56
                }
57 2
                $return .= "</div>";
58
            }
59
        }
60
61 2
        return $return;
62
    }
63
}