| Total Complexity | 6 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class LoadEnvironmentVariables |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The directory containing the environment file. |
||
| 14 | * |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $filePath; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The name of the environment file. |
||
| 21 | * |
||
| 22 | * @var string|null |
||
| 23 | */ |
||
| 24 | protected $fileName; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Create a new loads environment variables instance. |
||
| 28 | * |
||
| 29 | * @param string $path |
||
| 30 | * @param string|null $name |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function __construct($path, $name = null) |
||
| 34 | { |
||
| 35 | $this->filePath = $path; |
||
| 36 | $this->fileName = $name; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Setup the environment variables. |
||
| 41 | * |
||
| 42 | * If no environment file exists, we continue silently. |
||
| 43 | * |
||
| 44 | * @return void |
||
| 45 | */ |
||
| 46 | public function bootstrap() |
||
| 47 | { |
||
| 48 | try { |
||
| 49 | $this->createDotenv()->safeLoad(); |
||
| 50 | } catch (InvalidFileException $e) { |
||
| 51 | $this->writeErrorAndDie([ |
||
| 52 | 'The environment file is invalid!', |
||
| 53 | $e->getMessage(), |
||
| 54 | ]); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Create a Dotenv instance. |
||
| 60 | * |
||
| 61 | * @return \Dotenv\Dotenv |
||
| 62 | */ |
||
| 63 | protected function createDotenv() |
||
| 64 | { |
||
| 65 | return Dotenv::create( |
||
| 66 | Env::getRepository(), |
||
| 67 | $this->filePath, |
||
| 68 | $this->fileName |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Write the error information to the screen and exit. |
||
| 74 | * |
||
| 75 | * @param string[] $errors |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | protected function writeErrorAndDie(array $errors) |
||
| 87 | } |
||
| 88 | } |
||
| 89 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths