| Conditions | 4 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public static function getConfig( |
||
| 37 | ?string $configPath, |
||
| 38 | ConfigurationHelper $helper, |
||
| 39 | SymfonyStyle $io, |
||
| 40 | bool $allowNoFile |
||
| 41 | ): Configuration { |
||
| 42 | try { |
||
| 43 | $configPath = $configPath ?? $helper->findDefaultPath(); |
||
| 44 | |||
| 45 | $io->comment( |
||
| 46 | sprintf( |
||
| 47 | 'Loading the configuration file "<comment>%s</comment>".', |
||
| 48 | $configPath |
||
| 49 | ) |
||
| 50 | ); |
||
| 51 | } catch (NoConfigurationFound $exception) { |
||
| 52 | if (false === $allowNoFile) { |
||
| 53 | throw $exception; |
||
| 54 | } |
||
| 55 | |||
| 56 | $io->comment('Loading without a configuration file.'); |
||
| 57 | |||
| 58 | $configPath = null; |
||
| 59 | } |
||
| 60 | |||
| 61 | try { |
||
| 62 | return $helper->loadFile($configPath); |
||
| 63 | } catch (InvalidArgumentException $exception) { |
||
| 64 | $io->error('The configuration file is invalid.'); |
||
| 65 | |||
| 66 | throw $exception; |
||
| 67 | } |
||
| 70 |