MethodSignature   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 3
1
<?php namespace Comodojo\RpcServer\Introspection;
2
3
use \Comodojo\RpcServer\Request\Parameters;
4
use \Comodojo\Exception\RpcException;
5
6
/**
7
 * The system.methodSignature method implementation
8
 *
9
 * @package     Comodojo Spare Parts
10
 * @author      Marco Giovinazzi <[email protected]>
11
 * @license     MIT
12
 *
13
 * LICENSE:
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 */
23
24
class MethodSignature {
25
26
    /**
27
     * Execute call
28
     *
29
     * @param Parameters $params
30
     *
31
     * @return array
32
     * @throws RpcException
33
     */
34 15
    final public static function execute(Parameters $params) {
35
36 15
        $asked_method = $params->get('method');
37
38 15
        $method = $params->methods()->get($asked_method);
0 ignored issues
show
Deprecated Code introduced by
The function Comodojo\RpcServer\Request\Parameters::methods() has been deprecated. ( Ignorable by Annotation )

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

38
        $method = /** @scrutinizer ignore-deprecated */ $params->methods()->get($asked_method);
Loading history...
39
40 15
        if ( is_null($method) ) throw new RpcException("Method not found", -32601);
41
42 15
        $signatures = $method->getSignatures();
43
44 15
        return sizeof($signatures) == 1 ? $signatures[0] : $signatures;
45
46
    }
47
48
}
49