GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RpcEncoded   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 47.62%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 41
loc 41
rs 10
c 0
b 0
f 0
ccs 10
cts 21
cp 0.4762

6 Methods

Rating   Name   Duplication   Size   Complexity  
A bindingStyle() 4 4 1
A bindingUse() 4 4 1
A methodInput() 8 8 2
A methodOutput() 5 5 1
A typeParameters() 8 8 2
A typeReturning() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Copyright (C) 2013-2015
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
namespace WSDL\XML\Styles;
25
26
use WSDL\Parser\MethodParser;
27
28
/**
29
 * RpcEncoded
30
 *
31
 * @author Piotr Olaszewski <[email protected]>
32
 */
33 View Code Duplication
class RpcEncoded extends Style
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
{
35 1
    public function bindingStyle()
36
    {
37 1
        return 'rpc';
38
    }
39
40 1
    public function bindingUse()
41
    {
42 1
        return 'encoded';
43
    }
44
45
    public function methodInput(MethodParser $method)
46
    {
47
        $partElements = array();
48
        foreach ($method->parameters() as $parameter) {
49
            $partElements[] = $this->_createElement($parameter);
0 ignored issues
show
Documentation introduced by
$parameter is of type object<WSDL\Parser\ParameterParser>, but the function expects a object<WSDL\Types\Type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
        }
51
        return $partElements;
52
    }
53
54
    public function methodOutput(MethodParser $method)
55
    {
56
        $returnElement = $this->_createElement($method->returning());
0 ignored issues
show
Bug introduced by
It seems like $method->returning() targeting WSDL\Parser\MethodParser::returning() can also be of type array<integer,object<WSD...arser\ParameterParser>>; however, WSDL\XML\Styles\Style::_createElement() does only seem to accept object<WSDL\Types\Type>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
57
        return $returnElement;
58
    }
59
60 6
    public function typeParameters(MethodParser $method)
61
    {
62 6
        $elements = array();
63 6
        foreach ($method->parameters() as $parameter) {
64 6
            $elements[] = $this->_generateType($parameter);
65 6
        }
66 6
        return $elements;
67
    }
68
69
    public function typeReturning(MethodParser $method)
70
    {
71
        return $this->_generateType($method->returning());
72
    }
73
}
74