Skip to content

Commit

Permalink
Generator work for resource type is close
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed May 15, 2023
1 parent b5b1002 commit 34e5a29
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Generators/ResponseType/EnumTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function handle(GeneratorRepository $generatorRepository): void
$token = "//case TemplateType = 'template_type'";
$case = "\n case [RESOURCE_CLASS_NAME] = '[RESOURCE_KEY]';";
$case = TokenReplacer::handle($generatorRepository, $case);
$replaceWith = sprintf("%s/%s", $token, $case);
$replaceWith = sprintf('%s/%s', $token, $case);

$contents = str($contents)
->replace($token, $replaceWith)
Expand Down
4 changes: 2 additions & 2 deletions app/Generators/ResponseType/GeneratorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Generators\ResponseType;

use Facades\App\Generators\ResponseType\ControllerTransformer;
use Facades\App\Generators\ResponseType\EnumTransformer;
use Facades\App\Generators\ResponseType\RoutesTransformer;
use Facades\App\Generators\ResponseType\VueTransformer;
use Facades\App\Generators\ResponseType\EnumTransformer;
use Illuminate\Support\Facades\File;

class GeneratorRepository
Expand Down Expand Up @@ -61,6 +61,6 @@ public function putFile(string $pathWithName, string $content)

public function getRootPathOrStubs(): string
{
return base_path("STUBS/");
return base_path('STUBS/');
}
}
2 changes: 1 addition & 1 deletion app/Generators/ResponseType/VueTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function makeVue()
$transformed = TokenReplacer::handle($this->generatorRepository, $content);

if ($file->getFilename() === 'ResourceForm.vue') {
$destination = $rootPath . '/Partials/ResourceForm.vue';
$destination = $rootPath.'/Partials/ResourceForm.vue';
} else {
$destination = sprintf('%s/%s',
$rootPath,
Expand Down
1 change: 0 additions & 1 deletion app/ResponseType/ResponseTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

enum ResponseTypeEnum: string
{

//case TemplateType = 'template_type'
case EmbedQuestion = 'embed_question';
case VectorSearch = 'vector_search';
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/EnumTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Generators\ResponseType\EnumTransformer;
use App\Generators\ResponseType\GeneratorRepository;
use App\Generators\ResponseType\RoutesTransformer;
use Illuminate\Support\Facades\File;
use Tests\TestCase;

Expand Down Expand Up @@ -35,7 +34,7 @@ enum ResponseTypeEnum: string
->withArgs(function ($filePath, $content) {
$this->assertStringContainsString("case FooBar = 'foo_bar'", $content);
$this->assertStringContainsString("case EmbedQuestion = 'embed_question'", $content);
$this->assertStringContainsString("enum ResponseTypeEnum: string", $content);
$this->assertStringContainsString('enum ResponseTypeEnum: string', $content);

return true;
});
Expand Down

0 comments on commit 34e5a29

Please sign in to comment.