Conditions | 6 |
Paths | 17 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
9 | public function run() |
||
10 | { |
||
11 | // job name to process |
||
12 | $job = getenv('BASIS_JOB'); |
||
13 | if (!$job) { |
||
14 | throw new Exception("BASIS_JOB is not defined"); |
||
15 | } |
||
16 | |||
17 | // loops count limit |
||
18 | $loops = +getenv('BASIS_LOOPS') ?: (getenv('BASIS_ENVIRONMENT') == 'dev' ? 1 : 100); |
||
19 | $current = 1; |
||
20 | |||
21 | // delay between calls in milliseconds |
||
22 | $delay = +getenv('BASIS_DELAY') ?: 0; |
||
|
|||
23 | |||
24 | while ($loops--) { |
||
25 | echo '#', $current++," ", $job, PHP_EOL; |
||
26 | ob_flush(); |
||
27 | |||
28 | $start = microtime(true); |
||
29 | $result = $this->dispatch($job); |
||
30 | echo "time: ", microtime(true) - $start, PHP_EOL; |
||
31 | |||
32 | echo json_encode($result, JSON_PRETTY_PRINT), PHP_EOL; |
||
33 | usleep($this->delay * 1000); |
||
34 | } |
||
35 | }} |
||
36 |
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.