These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use GuzzleHttp\Client; |
||
4 | |||
5 | class DataslangApi { |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | const BASE_URI = 'http://api.dataslang.com'; |
||
8 | |||
9 | private $client = null; |
||
10 | private $settings = array(); |
||
11 | private $timeout = 2.0; |
||
12 | |||
13 | public function __construct(){ |
||
14 | $this->initSettings(); |
||
15 | $this->client = new Client($this->settings); |
||
16 | } |
||
17 | |||
18 | public function validate($xml, $xsd){ |
||
0 ignored issues
–
show
|
|||
19 | $result = null; |
||
20 | |||
21 | try { |
||
22 | |||
23 | |||
24 | // $response = $this->client->request('POST', '/validate', [ |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
25 | // 'form_params' => [ |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
26 | // 'field_name' => 'abc', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
27 | // 'other_field' => '123', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
28 | // 'nested_field' => [ |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
29 | // 'nested' => 'hello' |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
30 | // ] |
||
31 | // ] |
||
32 | // ]); |
||
33 | |||
34 | $response = $this->client->request('POST', '/validate', [ |
||
0 ignored issues
–
show
$response is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
35 | 'form_params' => [ |
||
36 | 'parametro' => 'prova' |
||
37 | ] |
||
38 | ]); |
||
39 | |||
40 | $result = $res->getBody(); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | } catch (\Exception $e) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
43 | |||
44 | } |
||
45 | |||
46 | return $result; |
||
47 | } |
||
48 | |||
49 | private function initSettings(){ |
||
50 | $this->settings['base_uri'] = $this->getBaseUri(); |
||
51 | $this->settings['timeout'] = $this->getTimeout(); |
||
52 | } |
||
53 | |||
54 | public function setTimeout($timeout){ |
||
55 | $this->timeout = $timeout; |
||
56 | } |
||
57 | |||
58 | public function getTimeout(){ |
||
59 | return $this->timeout; |
||
60 | } |
||
61 | |||
62 | public function getBaseUri(){ |
||
63 | return self::BASE_URI; |
||
64 | } |
||
65 | |||
66 | } |
||
67 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.