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   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 59
Duplicated Lines 5.08 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 73.91%

Importance

Changes 0
Metric Value
dl 3
loc 59
ccs 17
cts 23
cp 0.7391
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A warning() 0 4 1
A info() 0 4 1
A success() 0 4 1
A error() 0 4 1
D render() 3 28 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}