Skip to content

Commit

Permalink
less deps
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 2, 2024
1 parent 34eed1b commit 5e8440a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"require": {
"php": ">=8.2",
"symfony/console": "^6.4",
"symfony/process": "^7.0",
"webmozart/assert": "^1.11"
"symfony/process": "^7.0"
},
"require-dev": {
"phpstan/extension-installer": "^1.3",
Expand Down
9 changes: 9 additions & 0 deletions src/Exception/ShouldNotHappenException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace TomasVotruba\PHPStanBodyscan\Exception;

final class ShouldNotHappenException extends \Exception
{
}
7 changes: 5 additions & 2 deletions src/Utils/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace TomasVotruba\PHPStanBodyscan\Utils;

use TomasVotruba\PHPStanBodyscan\Exception\ShouldNotHappenException;
use Webmozart\Assert\Assert;

final class FileLoader
Expand All @@ -13,11 +14,13 @@ final class FileLoader
*/
public static function resolveEnvVariablesFromFile(string $envFile): array
{
Assert::fileExists($envFile);
if (! file_exists($envFile)) {
throw new ShouldNotHappenException(sprintf('Env file "%s" was not found.', $envFile));
}

// load env file
/** @var string $envContent */
$envContent = file_get_contents($envFile);
Assert::string($envContent);

$envLines = explode("\n", $envContent);

Expand Down

0 comments on commit 5e8440a

Please sign in to comment.