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