Passed
Push — feature/code_improvement ( ee2f22...15c17b )
by Thierry
03:25 queued 42s
created

Message::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
nc 1
nop 2
rs 10
1
<?php
2
3
/**
4
 * Message.php - Interface for alert messages.
5
 *
6
 * @package jaxon-dialogs
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-dialogs" is not valid; consider "Jaxondialogs" instead
Loading history...
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2016 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
12
13
namespace Jaxon\Utils\Dialogs;
14
15
class Message implements \Jaxon\Contracts\Dialogs\Message
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Message
Loading history...
16
{
17
    use \Jaxon\Features\Dialogs\Message;
18
19
    /**
20
     * Print an alert message.
21
     *
22
     * @param string              $message              The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 14 found
Loading history...
23
     *
24
     * @return string|void
25
     */
26
    private function alert($message)
27
    {
28
        if($this->getReturn())
29
        {
30
            return 'alert(' . $message . ')';
31
        }
32
    }
33
34
    /**
35
     * Print a success message.
36
     *
37
     * @param string              $message              The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter type; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 14 found
Loading history...
38
     * @param string|null         $title                The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 16 found
Loading history...
39
     *
40
     * @return string|void
41
     */
42
    public function success($message, $title = null)
43
    {
44
        return $this->alert($message);
45
    }
46
47
    /**
48
     * Print an information message.
49
     *
50
     * @param string              $message              The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter type; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 14 found
Loading history...
51
     * @param string|null         $title                The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 16 found
Loading history...
52
     *
53
     * @return string|void
54
     */
55
    public function info($message, $title = null)
56
    {
57
        return $this->alert($message);
58
    }
59
60
    /**
61
     * Print a warning message.
62
     *
63
     * @param string              $message              The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter type; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 14 found
Loading history...
64
     * @param string|null         $title                The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 16 found
Loading history...
65
     *
66
     * @return string|void
67
     */
68
    public function warning($message, $title = null)
69
    {
70
        return $this->alert($message);
71
    }
72
73
    /**
74
     * Print an error message.
75
     *
76
     * @param string              $message              The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter type; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 14 found
Loading history...
77
     * @param string|null         $title                The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 16 found
Loading history...
78
     *
79
     * @return string|void
80
     */
81
    public function error($message, $title = null)
82
    {
83
        return $this->alert($message);
84
    }
85
}
86