Passed
Push — master ( 6084dc...68443e )
by Mihail
05:40
created

Apps/View/Install/default/macro/notify.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 31.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

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

Loading history...
2
/** @var $notify array */
3
4
use Ffcms\Core\Helper\Type\Obj;
5
6
/**
7
 * Get html css class from notify response type
8
 * @param string $type
9
 * @return string
10
 */
11 View Code Duplication
function type2html($type)
0 ignored issues
show
The function type2html() has been defined more than once; this definition is ignored, only the first definition in Apps/View/Admin/default/macro/notify.php (L11-28) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
12
{
13
    switch ($type) {
14
        case 'error':
15
            $htmlType = 'alert-danger';
16
            break;
17
        case 'success':
18
            $htmlType = 'alert-success';
19
            break;
20
        case 'warning':
21
            $htmlType = 'alert-warning';
22
            break;
23
        default:
24
            $htmlType = 'alert-info';
25
            break;
26
    }
27
    return $htmlType;
28
}
29
30
if (Obj::isArray($notify) && count($notify) > 0) {
31
    foreach ($notify as $type => $messages) {
32
        foreach ($messages as $message) {
33
            echo '<p class="alert ' . type2html($type) . '">
34
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'
35
                . \Ffcms\Core\App::$Security->strip_tags($message) . '</p>';
36
        }
37
    }
38
}
39