Passed
Push — master ( 98205f...6f7a23 )
by Thierry
02:22
created

CallMessageTrait::elseInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Request\Call\Traits;
4
5
use Jaxon\Request\Call\Call;
6
use Jaxon\Request\Call\Parameter;
7
8
use function array_map;
9
use function func_get_args;
10
11
trait CallMessageTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait CallMessageTrait
Loading history...
12
{
13
    /**
14
     * The type of the message to show
15
     *
16
     * @var string
17
     */
18
    private $sMessageType = 'warning';
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
19
20
    /**
21
     * The arguments of the elseShow() call
22
     *
23
     * @var array
24
     */
25
    protected $aMessageArgs = [];
26
27
    /**
28
     * Set the message if the condition to the call is not met
29
     *
30
     * The first parameter is the message to show. The second allows inserting data from
31
     * the webpage in the message using positional placeholders.
32
     *
33
     * @param string $sMessageType  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
34
     * @param array $aMessageArgs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
35
     *
36
     * @return Call
37
     */
38
    private function setMessage(string $sMessageType, array $aMessageArgs): Call
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
39
    {
40
        $this->sMessageType = $sMessageType;
41
        $this->aMessageArgs = array_map(function($xParameter) {
42
            return Parameter::make($xParameter);
43
        }, $aMessageArgs);
44
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Jaxon\Request\Call\Traits\CallMessageTrait which includes types incompatible with the type-hinted return Jaxon\Request\Call\Call.
Loading history...
45
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
46
47
    /**
48
     * Show a message if the condition to the call is not met
49
     *
50
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
51
     *
52
     * @return Call
53
     */
54
    public function elseShow(string $sMessage): Call
55
    {
56
        return $this->setMessage('warning', func_get_args());
57
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
58
59
    /**
60
     * Show an information message if the condition to the call is not met
61
     *
62
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
63
     *
64
     * @return Call
65
     */
66
    public function elseInfo(string $sMessage): Call
67
    {
68
        return $this->setMessage('info', func_get_args());
69
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
70
71
    /**
72
     * Show a success message if the condition to the call is not met
73
     *
74
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
75
     *
76
     * @return Call
77
     */
78
    public function elseSuccess(string $sMessage): Call
79
    {
80
        return $this->setMessage('success', func_get_args());
81
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
82
83
    /**
84
     * Show a warning message if the condition to the call is not met
85
     *
86
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
87
     *
88
     * @return Call
89
     */
90
    public function elseWarning(string $sMessage): Call
91
    {
92
        return $this->setMessage('warning', func_get_args());
93
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
94
95
    /**
96
     * Show an error message if the condition to the call is not met
97
     *
98
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
99
     *
100
     * @return Call
101
     */
102
    public function elseError(string $sMessage): Call
103
    {
104
        return $this->setMessage('error', func_get_args());
105
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
106
}
107