Conditions | 7 |
Paths | 10 |
Total Lines | 27 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function validate($value, Constraint $constraint) |
||
19 | { |
||
20 | $match = false; |
||
21 | if (strpos($value, '/') === 0) { |
||
22 | $routeCollection = $this->router->getRouteCollection()->all(); |
||
23 | foreach ($routeCollection as $name => $route) { |
||
24 | if ($match = $route->getPath() === $value) { |
||
25 | break; |
||
26 | } |
||
27 | } |
||
28 | } else { |
||
29 | $handle = curl_init($value); |
||
30 | curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); |
||
31 | $response = curl_exec($handle); |
||
|
|||
32 | $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); |
||
33 | |||
34 | if ($httpCode >= 200 && $httpCode < 300) { |
||
35 | $match = true; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | if ($match === false) { |
||
40 | $this->context->buildViolation($constraint->message) |
||
41 | ->setParameter('%string%', $value) |
||
42 | ->addViolation(); |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.