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.

WrapperCommand::execute()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 25

Duplication

Lines 35
Ratio 100 %

Importance

Changes 0
Metric Value
dl 35
loc 35
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 25
nc 1
nop 2
1
<?php
2
namespace Clients\RpcEncoded;
3
4
use Clients\InitCommand;
5
use SoapClient;
6
use stdClass;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10 View Code Duplication
class WrapperCommand extends InitCommand
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...
11
{
12
    protected function configure()
13
    {
14
        $this->setName('rpc_encoded:wrapper');
15
    }
16
17
    protected function execute(InputInterface $input, OutputInterface $output)
18
    {
19
        $this->output = $output;
20
21
        $this->soapClient = new SoapClient('http://localhost/wsdl-creator/examples/rpc_encoded/WrapperExampleSoapServer.php?wsdl', array(
22
            'uri' => "http://foo.bar/", 'location' => 'http://localhost/wsdl-creator/examples/rpc_encoded/WrapperExampleSoapServer.php',
23
            'trace' => true, 'cache_wsdl' => WSDL_CACHE_NONE
24
        ));
25
26
        $this->serviceInfo('Wrapper Object - rpc/encoded');
27
28
        $this->renderMethodsTable();
29
30
        $user = new stdClass();
31
        $user->name = 'john';
32
        $user->age = 31;
33
        $user->payment = 123.40;
34
        $response = $this->soapClient->getUserString($user, 333);
35
        $this->method('getUserString', array($user, 333), $response);
36
37
        $response = $this->soapClient->getUser('peter', 22, 32.02);
38
        $this->method('getUser', array('peter', 22, 32.02), $response);
39
40
        $response = $this->soapClient->getEmployees();
41
        $this->method('getEmployees', array(), $response);
42
43
        $employees[0] = new stdClass();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$employees was never initialized. Although not strictly required by PHP, it is generally a good practice to add $employees = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
44
        $employees[0]->id = 1;
45
        $employees[0]->department = 'IT';
46
        $employees[1] = new stdClass();
47
        $employees[1]->id = 2;
48
        $employees[1]->department = 'Logistic';
49
        $response = $this->soapClient->getEmployeesDepartments($employees);
50
        $this->method('getEmployeesDepartments', array($employees), $response);
51
    }
52
}