Conditions | 3 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
46 | protected function testExists(array $connect, $expectExists, array $task) |
||
47 | { |
||
48 | $exists = true; |
||
49 | $msg = 'Connection exists'; |
||
50 | |||
51 | try { |
||
52 | $pdo = $this->createInstance($connect); |
||
|
|||
53 | } catch (\Exception $ex) { |
||
54 | $exists = false; |
||
55 | $msg = "Unable to connect to database. " . $ex->getMessage(); |
||
56 | } |
||
57 | |||
58 | if ($exists === $expectExists) { |
||
59 | throw new SuccessException('Ok', $task); |
||
60 | } |
||
61 | |||
62 | throw new FailException($msg, $task); |
||
63 | } |
||
64 | } |
||
65 |
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.