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

NotifyLibrary::info()   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
 * NotifyLibrary.php
5
 *
6
 * Adapter for the Notify 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\Notify;
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 NotifyLibrary implements MessageInterface
22
{
23
    use DialogLibraryTrait;
24
    use MessageTrait;
25
26
    /**
27
     * @const The library name
28
     */
29
    const NAME = 'notify';
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 'notify';
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function getVersion(): string
51
    {
52
        return '0.4.2';
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58
    public function getJs(): string
59
    {
60
        return $this->helper()->getJsCode('notify.js');
61
    }
62
63
    /**
64
     * @inheritDoc
65
     */
66
    public function getScript(): string
67
    {
68
        return $this->helper()->render('notify/alert.js');
69
    }
70
71
    /**
72
     * @inheritDoc
73
     */
74
    public function getReadyScript(): string
75
    {
76
        return $this->helper()->render('notify/ready.js.php');
77
    }
78
79
    /**
80
     * @inheritDoc
81
     */
82
    protected function alert(string $sMessage, string $sTitle, string $sStdType)
83
    {
84
        $aTypes = [
85
            'warning' => 'warn',
86
        ];
87
        $sClass = $aTypes[$sStdType] ?? $sStdType;
88
        $this->addCommand('notify.alert', ['message' => $sMessage, 'className' => $sClass]);
0 ignored issues
show
Bug introduced by
'notify.alert' of type string is incompatible with the type array expected by parameter $aAttributes of Jaxon\Dialogs\Notify\NotifyLibrary::addCommand(). ( Ignorable by Annotation )

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

88
        $this->addCommand(/** @scrutinizer ignore-type */ 'notify.alert', ['message' => $sMessage, 'className' => $sClass]);
Loading history...
89
    }
90
}
91