Conditions | 7 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
20 | public function resolve(Schema $schema): string |
||
21 | { |
||
22 | $typePattern = '.*'; |
||
23 | |||
24 | switch ($type = $schema->getType()) { |
||
|
|||
25 | case Schema::TYPE_INT: |
||
26 | $typePattern = '\d+'; |
||
27 | break; |
||
28 | case Schema::TYPE_NUMBER: |
||
29 | $typePattern = '\d+(\.\d+)?'; |
||
30 | break; |
||
31 | case Schema::TYPE_NULL: |
||
32 | $typePattern = 'null'; |
||
33 | break; |
||
34 | case Schema::TYPE_STRING: |
||
35 | /** @var $schema ScalarSchema $routeString */ |
||
36 | if ($pattern = $schema->getPattern()) { |
||
37 | $typePattern = $pattern; |
||
38 | } elseif ($enum = $schema->getEnum()) { |
||
39 | $typePattern = '(' . implode('|', $enum) . ')'; |
||
40 | } |
||
41 | break; |
||
42 | default: |
||
43 | return $typePattern; |
||
44 | } |
||
45 | |||
46 | return $typePattern; |
||
47 | } |
||
48 | } |
||
49 |
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.