Passed
Push — v5.x ( 0160d0 )
by Thierry
09:10
created

ToastrLibrary::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * ToastrLibrary.php
5
 *
6
 * Adapter for the Toastr library.
7
 *
8
 * @package jaxon-dialogs
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-dialogs
13
 */
14
15
namespace Jaxon\Dialogs\Toastr;
16
17
use Jaxon\App\Dialog\Library\DialogLibraryTrait;
18
use Jaxon\App\Dialog\Library\MessageTrait;
0 ignored issues
show
Bug introduced by
The type Jaxon\App\Dialog\Library\MessageTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Jaxon\App\Dialog\MessageInterface;
20
21
class ToastrLibrary implements MessageInterface
22
{
23
    use DialogLibraryTrait;
24
    use MessageTrait;
25
26
    /**
27
     * @const The library name
28
     */
29
    const NAME = 'toastr';
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function getName(): string
35
    {
36
        return self::NAME;
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function getSubdir(): string
43
    {
44
        return 'toastr.js';
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function getVersion(): string
51
    {
52
        return '2.1.3';
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58
    public function getJs(): string
59
    {
60
        return $this->helper()->getJsCode('toastr.min.js');
61
    }
62
63
    /**
64
     * @inheritDoc
65
     */
66
    public function getCss(): string
67
    {
68
        return $this->helper()->getCssCode('toastr.min.css');
69
    }
70
71
    /**
72
     * @inheritDoc
73
     */
74
    public function getScript(): string
75
    {
76
        return $this->helper()->render('toastr/alert.js');
77
    }
78
79
    /**
80
     * @inheritDoc
81
     */
82
    public function getReadyScript(): string
83
    {
84
        return $this->helper()->render('toastr/ready.js.php', [
85
            'options' =>  $this->helper()->getOptionScript('toastr.options.', 'options.')
86
        ]);
87
    }
88
89
    /**
90
     * @inheritDoc
91
     */
92
    protected function alert(string $sMessage, string $sTitle, string $sType)
93
    {
94
        $this->addCommand('toastr.' . $sType, ['message' => $sMessage, 'title' => $sTitle]);
0 ignored issues
show
Bug introduced by
'toastr.' . $sType of type string is incompatible with the type array expected by parameter $aAttributes of Jaxon\Dialogs\Toastr\ToastrLibrary::addCommand(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

94
        $this->addCommand(/** @scrutinizer ignore-type */ 'toastr.' . $sType, ['message' => $sMessage, 'title' => $sTitle]);
Loading history...
95
    }
96
97
    public function remove()
98
    {
99
        $this->addCommand('toastr.remove');
0 ignored issues
show
Bug introduced by
'toastr.remove' of type string is incompatible with the type array expected by parameter $aAttributes of Jaxon\Dialogs\Toastr\ToastrLibrary::addCommand(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
        $this->addCommand(/** @scrutinizer ignore-type */ 'toastr.remove');
Loading history...
Bug introduced by
The call to Jaxon\Dialogs\Toastr\ToastrLibrary::addCommand() has too few arguments starting with xData. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
        $this->/** @scrutinizer ignore-call */ 
100
               addCommand('toastr.remove');

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
100
    }
101
102
    public function clear()
103
    {
104
        $this->addCommand('toastr.clear');
0 ignored issues
show
Bug introduced by
The call to Jaxon\Dialogs\Toastr\ToastrLibrary::addCommand() has too few arguments starting with xData. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
        $this->/** @scrutinizer ignore-call */ 
105
               addCommand('toastr.clear');

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
'toastr.clear' of type string is incompatible with the type array expected by parameter $aAttributes of Jaxon\Dialogs\Toastr\ToastrLibrary::addCommand(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

104
        $this->addCommand(/** @scrutinizer ignore-type */ 'toastr.clear');
Loading history...
105
    }
106
}
107