Conditions | 4 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
30 | 2 | public function __construct(AppConfig $config, ILogger $logger) { |
|
31 | 6 | parent::__construct($config, $logger); |
|
32 | |||
33 | $this->avHost = $this->appConfig->getAvHost(); |
||
34 | $this->avPort = $this->appConfig->getAvPort(); |
||
35 | $checks = [ |
||
36 | 6 | 'hostname' => $this->avHost, |
|
37 | 2 | 'port' => $this->avPort |
|
38 | 2 | ]; |
|
39 | $errors = []; |
||
40 | foreach ($checks as $key => $check) { |
||
41 | if ($check === '') { |
||
42 | 4 | $errors[] = sprintf( |
|
43 | 4 | 'Daemon mode requires a %s but it is empty.', |
|
44 | 2 | $key |
|
45 | 2 | ); |
|
46 | 2 | } |
|
47 | } |
||
48 | |||
49 | if (count($errors) > 0) { |
||
50 | 2 | throw new InitException( |
|
51 | 'The app is not configured properly. ' . implode(' ', $errors) |
||
52 | 2 | ); |
|
53 | 2 | } |
|
54 | } |
||
55 | |||
73 |
If you suppress an error, we recommend checking for the error condition explicitly: