Passed
Push — master ( 729ca2...5212d6 )
by Thierry
02:19
created

Target::method()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Target.php - Jaxon Request Target
5
 *
6
 * This class contains the name of the function or class and method targetted by a Jaxon request.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
11
 * @link https://github.com/jaxon-php/jaxon-core
12
 */
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...
13
14
namespace Jaxon\Request;
15
16
class Target implements TargetInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Target
Loading history...
17
{
18
    /**
19
     * The target type for function.
20
     *
21
     * @var string
22
     */
23
    const TYPE_FUNCTION = 'TargetFunction';
24
25
    /**
26
     * The target type for class.
27
     *
28
     * @var string
29
     */
30
    const TYPE_CLASS = 'TargetClass';
31
32
    /**
33
     * The target type.
34
     *
35
     * @var string
36
     */
37
    private $sType = '';
38
39
    /**
40
     * The target function name.
41
     *
42
     * @var string
43
     */
44
    private $sFunctionName = '';
45
46
    /**
47
     * The target class name.
48
     *
49
     * @var string
50
     */
51
    private $sClassName = '';
52
53
    /**
54
     * The target method name.
55
     *
56
     * @var string
57
     */
58
    private $sMethodName = '';
59
60
    /**
61
     * The target method args.
62
     *
63
     * @var array
64
     */
65
    private $aMethodArgs = [];
66
67
    /**
68
     * The constructor
69
     *
70
     * @param string $sType    The target type
0 ignored issues
show
Coding Style introduced by
Expected 9 spaces after parameter name; 4 found
Loading history...
71
     * @param string $sFunctionName    The function name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
72
     * @param string $sClassName    The class name
73
     * @param string $sMethodName    The method name
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
74
     * @param array $aMethodArgs    The method args
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
75
     */
76
    private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = [])
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
77
    {
78
        $this->sType = $sType;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
79
        $this->sFunctionName = $sFunctionName;
80
        $this->sClassName = $sClassName;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
81
        $this->sMethodName = $sMethodName;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
82
        $this->aMethodArgs = $aMethodArgs;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
83
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
84
85
    /**
86
     * Create a target of type Function
87
     *
88
     * @param string $sFunctionName    The function name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
89
     *
90
     * @return Target
91
     */
92
    public static function makeFunction(string $sFunctionName): Target
93
    {
94
        return new Target(self::TYPE_FUNCTION, $sFunctionName, '', '');
95
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
96
97
    /**
98
     * Create a target of type Class
99
     *
100
     * @param string $sClassName    The class name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
101
     * @param string $sMethodName    The method name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
102
     *
103
     * @return Target
104
     */
105
    public static function makeClass(string $sClassName, string $sMethodName): Target
106
    {
107
        return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName);
108
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
109
110
    /**
111
     * Check if the target type is Function.
112
     *
113
     * @return bool
114
     */
115
    public function isFunction(): bool
116
    {
117
        return $this->sType === self::TYPE_FUNCTION;
118
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
119
120
    /**
121
     * Check if the target type is Class.
122
     *
123
     * @return bool
124
     */
125
    public function isClass(): bool
126
    {
127
        return $this->sType === self::TYPE_CLASS;
128
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
129
130
    /**
131
     * The target function name.
132
     *
133
     * @return string
134
     */
135
    public function getFunctionName(): string
136
    {
137
        return $this->sFunctionName;
138
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
139
140
    /**
141
     * The target class name.
142
     *
143
     * @return string
144
     */
145
    public function getClassName(): string
146
    {
147
        return $this->sClassName;
148
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
149
150
    /**
151
     * The target method name.
152
     *
153
     * @return string
154
     */
155
    public function getMethodName(): string
156
    {
157
        return $this->sMethodName;
158
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
159
160
    /**
161
     * Set the target method name.
162
     *
163
     * @param array $aMethodArgs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
164
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
165
    public function setMethodArgs(array $aMethodArgs): void
166
    {
167
        $this->aMethodArgs = $aMethodArgs;
168
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
169
170
    /**
171
     * The target method args.
172
     *
173
     * @return array
174
     */
175
    public function getMethodArgs(): array
176
    {
177
        return $this->aMethodArgs;
178
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
179
180
    /**
181
     * The target method name.
182
     *
183
     * @return string
184
     */
185
    public function method(): string
186
    {
187
        return $this->sMethodName;
188
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
189
190
    /**
191
     * The target method args.
192
     *
193
     * @return array
194
     */
195
    public function args(): array
196
    {
197
        return $this->aMethodArgs;
198
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
199
}
200