diff --git a/src/Commands/GenerateEnumsCommand.php b/src/Commands/GenerateEnumsCommand.php index 2ca3b21..1e5043e 100644 --- a/src/Commands/GenerateEnumsCommand.php +++ b/src/Commands/GenerateEnumsCommand.php @@ -48,7 +48,12 @@ public function handle(): int */ protected function enums(): Collection { - return DiscoverEnums::within(app_path(config()->string('paragon.enums.paths.php'))) + /** + * @var string $path + */ + $path = config('paragon.enums.paths.php'); + + return DiscoverEnums::within(app_path($path)) ->reject(function (ReflectionEnum $enum) { $paths = Arr::map( Arr::wrap(config('paragon.enums.paths.ignore')), diff --git a/src/Generators/EnumGenerator.php b/src/Generators/EnumGenerator.php index 1ccdb21..54167a9 100644 --- a/src/Generators/EnumGenerator.php +++ b/src/Generators/EnumGenerator.php @@ -27,8 +27,13 @@ class EnumGenerator */ public function __construct(protected ReflectionEnum $enum, protected EnumBuilder $builder) { + /** + * @var string $path + */ + $path = config('paragon.enums.paths.generated'); + static::$files = Storage::createLocalDriver([ - 'root' => resource_path(config()->string('paragon.enums.paths.generated')), + 'root' => resource_path($path), ]); static::$cache = Storage::createLocalDriver([ @@ -56,10 +61,15 @@ protected function contents(): string { $code = $this->prepareEnumCode(); + /** + * @var string $abstractName + */ + $abstractName = config('paragon.enums.abstract-class'); + return str(file_get_contents($this->builder->stubPath()) ?: null) ->replace('{{ Path }}', $this->relativePath()) ->replace('{{ Enum }}', $this->enum->getShortName()) - ->replace('{{ Abstract }}', config()->string('paragon.enums.abstract-class')) + ->replace('{{ Abstract }}', $abstractName) ->replace('{{ TypeDefinition }}', $code->get('type') ?? '') ->replace('{{ Cases }}', $code->get('cases') ?? '') ->replace('{{ Getters }}', $code->get('getters') ?? '');