From 84b7be9e6dc6f2d95c3f321fa34793bd18e94b3f Mon Sep 17 00:00:00 2001 From: "ryan.deng" Date: Mon, 12 Aug 2019 12:40:04 +1000 Subject: [PATCH] all --- composer.json | 2 +- .../{jsontoclassgenerator.php => dto-generator.php} | 0 readme.md | 4 ++-- src/Commands/JsonToClassGeneratorCommand.php | 11 +++++------ ...onGeneratorFactory.php => DTOGeneratorFactory.php} | 4 ++-- ...der.php => LaravelDTOGeneratorServiceProvider.php} | 10 +++++----- src/Services/AbstractClassGenerator.php | 6 +++--- src/Services/ArrayToClassGenerator.php | 4 ++-- src/Services/JsonToClassGenerator.php | 4 ++-- 9 files changed, 22 insertions(+), 23 deletions(-) rename config/{jsontoclassgenerator.php => dto-generator.php} (100%) rename src/{JsonGeneratorFactory.php => DTOGeneratorFactory.php} (89%) rename src/{LaravelJsonToClassGeneratorServiceProvider.php => LaravelDTOGeneratorServiceProvider.php} (67%) diff --git a/composer.json b/composer.json index 48b6984..0934c0d 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "array to json", "array to model", "json to class", - "dto generator + "dto generator" ], "require": { "illuminate/support": "~5", diff --git a/config/jsontoclassgenerator.php b/config/dto-generator.php similarity index 100% rename from config/jsontoclassgenerator.php rename to config/dto-generator.php diff --git a/readme.md b/readme.md index 135b620..1cd6e76 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ Install the package in development dependencies: Via Composer ``` bash -composer require --dev timehunter/laravel-json-to-class-generator "~1.0" +composer require --dev timehunter/laravel-json-to-class-generator "~2.0" ``` ## Installation @@ -28,7 +28,7 @@ php artisan vendor:publish --provider="TimeHunter\LaravelJsonToClassGenerator\La 2. Add your array schema in config 3. Run artisan command: ````bash -php artisan make:jsontoclass +php artisan make:dto ```` 4. Check your files under your specified file location diff --git a/src/Commands/JsonToClassGeneratorCommand.php b/src/Commands/JsonToClassGeneratorCommand.php index 62c3175..297e006 100644 --- a/src/Commands/JsonToClassGeneratorCommand.php +++ b/src/Commands/JsonToClassGeneratorCommand.php @@ -1,11 +1,10 @@ info('Classes generated. Please check them.'); } catch (\Exception $e) { Log::error($e); diff --git a/src/JsonGeneratorFactory.php b/src/DTOGeneratorFactory.php similarity index 89% rename from src/JsonGeneratorFactory.php rename to src/DTOGeneratorFactory.php index 907df7c..5cb2761 100644 --- a/src/JsonGeneratorFactory.php +++ b/src/DTOGeneratorFactory.php @@ -1,13 +1,13 @@ publishes([ - __DIR__.'/../config/jsontoclassgenerator.php' => config_path('jsontoclassgenerator.php'), - ], 'jsontoclassgenerator.config'); + __DIR__.'/../config/dto-generator.php' => config_path('dto-generator.php'), + ], 'dto-generator.config'); } } diff --git a/src/Services/AbstractClassGenerator.php b/src/Services/AbstractClassGenerator.php index b9693d8..7504a44 100644 --- a/src/Services/AbstractClassGenerator.php +++ b/src/Services/AbstractClassGenerator.php @@ -1,6 +1,6 @@ recursiveCreateFile($this->getData(), config('jsontoclassgenerator.namespace')); + $this->recursiveCreateFile($this->getData(), config('dto-generator.namespace')); } public function getType($value) @@ -156,7 +156,7 @@ private function recursiveCreateFile($sample, $namespaceString) $file = $className . '.php'; - $location = config('jsontoclassgenerator.file_location') . '/' . $file; + $location = config('dto-generator.file_location') . '/' . $file; File::put($location, $phpFile); } } diff --git a/src/Services/ArrayToClassGenerator.php b/src/Services/ArrayToClassGenerator.php index 9f727f6..7e39e79 100644 --- a/src/Services/ArrayToClassGenerator.php +++ b/src/Services/ArrayToClassGenerator.php @@ -1,6 +1,6 @@