Skip to content

Commit

Permalink
Fixed usage of L11 specific methods"
Browse files Browse the repository at this point in the history
  • Loading branch information
luisdalmolin committed Oct 29, 2024
1 parent d8e021e commit 6888bcb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Commands/GenerateEnumsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public function handle(): int
*/
protected function enums(): Collection
{
return DiscoverEnums::within(app_path((string) config('paragon.enums.paths.php')))
/** @var string */
$phpPath = config('paragon.enums.paths.php');

return DiscoverEnums::within(app_path($phpPath))
->reject(function ($enum) {
if (! enum_exists($enum)) {
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/MakeEnumMethodCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ protected function buildClass($name): string
*/
protected function getPath($name): string
{
/** @var string */
$methods = config('paragon.enums.paths.methods');
$extension = $this->option('javascript') ? 'js' : 'ts';

return resource_path(config()->string('paragon.enums.paths.methods')) . "/{$this->name()}.{$extension}";
return resource_path($methods) . "/{$this->name()}.{$extension}";
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/AbstractEnumGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ protected function imports(): Collection
return $fileCollection
->mapWithKeys(function (SplFileInfo $file): array {
$filesystem = new FileUtility();
/** @var string */
$generatedPath = config('paragon.enums.paths.generated');

$relativeFilePath = $filesystem->makePathRelative(
$file->getPath(),
resource_path(config()->string('paragon.enums.paths.generated'))
resource_path($generatedPath)
);

$name = (string) str($file->getFileName())->before('.');
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/EnumGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ public function __invoke(): bool
protected function contents(): string
{
$code = $this->prepareEnumCode();
/** @var string */
$abstractClass = config('paragon.enums.abstract-class');

return str(file_get_contents($this->builder->stubPath()) ?: null)
->replace('{{ Path }}', $this->relativePath())
->replace('{{ Enum }}', class_basename($this->enum))
->replace('{{ Abstract }}', config()->string('paragon.enums.abstract-class'))
->replace('{{ Abstract }}', $abstractClass)
->replace('{{ TypeDefinition }}', $code->get('type') ?? '')
->replace('{{ Cases }}', $code->get('cases') ?? '')
->replace('{{ Getters }}', $code->get('getters') ?? '');
Expand Down

0 comments on commit 6888bcb

Please sign in to comment.