Skip to content

Commit 84b7be9

Browse files
author
ryan.deng
committed
all
1 parent 6391c58 commit 84b7be9

File tree

9 files changed

+22
-23
lines changed

9 files changed

+22
-23
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"array to json",
2121
"array to model",
2222
"json to class",
23-
"dto generator
23+
"dto generator"
2424
],
2525
"require": {
2626
"illuminate/support": "~5",
File renamed without changes.

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Install the package in development dependencies:
1616
Via Composer
1717

1818
``` bash
19-
composer require --dev timehunter/laravel-json-to-class-generator "~1.0"
19+
composer require --dev timehunter/laravel-json-to-class-generator "~2.0"
2020
```
2121

2222
## Installation
@@ -28,7 +28,7 @@ php artisan vendor:publish --provider="TimeHunter\LaravelJsonToClassGenerator\La
2828
2. Add your array schema in config
2929
3. Run artisan command:
3030
````bash
31-
php artisan make:jsontoclass
31+
php artisan make:dto
3232
````
3333
4. Check your files under your specified file location
3434

src/Commands/JsonToClassGeneratorCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator\Commands;
3+
namespace TimeHunter\LaravelDTOGenerator\Commands;
44

55
use Illuminate\Console\Command;
66
use Illuminate\Support\Facades\Log;
7-
use TimeHunter\LaravelJsonToClassGenerator\JsonGeneratorFactory;
8-
use TimeHunter\LaravelJsonToClassGenerator\Services\JsonToClassGenerator;
7+
use TimeHunter\LaravelDTOGenerator\DTOGeneratorFactory;
98

109
class JsonToClassGeneratorCommand extends Command
1110
{
@@ -14,14 +13,14 @@ class JsonToClassGeneratorCommand extends Command
1413
*
1514
* @var string
1615
*/
17-
protected $signature = 'make:jsontoclass';
16+
protected $signature = 'make:dto';
1817

1918
/**
2019
* The console command description.
2120
*
2221
* @var string
2322
*/
24-
protected $description = 'Generate classes based on JSON';
23+
protected $description = 'Generate DTO based on Array schema';
2524

2625
/**
2726
* Create a new command instance.
@@ -41,7 +40,7 @@ public function __construct()
4140
public function handle()
4241
{
4342
try {
44-
JsonGeneratorFactory::generate(config('jsontoclassgenerator.driver'));
43+
DTOGeneratorFactory::generate(config('dto-generator.driver'));
4544
$this->info('Classes generated. Please check them.');
4645
} catch (\Exception $e) {
4746
Log::error($e);

src/JsonGeneratorFactory.php renamed to src/DTOGeneratorFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator;
3+
namespace TimeHunter\LaravelDTOGenerator;
44

55
use TimeHunter\LaravelJsonToClassGenerator\Services\ArrayToClassGenerator;
66

77
use Exception;
88
use TimeHunter\LaravelJsonToClassGenerator\Services\JsonToClassGenerator;
99

10-
class JsonGeneratorFactory
10+
class DTOGeneratorFactory
1111
{
1212

1313
/**

src/LaravelJsonToClassGeneratorServiceProvider.php renamed to src/LaravelDTOGeneratorServiceProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator;
3+
namespace TimeHunter\LaravelDTOGenerator;
44

55

66
use Illuminate\Support\ServiceProvider;
7-
use TimeHunter\LaravelJsonToClassGenerator\Commands\JsonToClassGeneratorCommand;
7+
use TimeHunter\LaravelDTOGenerator\Commands\JsonToClassGeneratorCommand;
88

9-
class LaravelJsonToClassGeneratorServiceProvider extends ServiceProvider
9+
class LaravelDTOGeneratorServiceProvider extends ServiceProvider
1010
{
1111
/**
1212
* Perform post-registration booting of services.
@@ -41,8 +41,8 @@ protected function bootForConsole()
4141
{
4242
// Publishing the configuration file.
4343
$this->publishes([
44-
__DIR__.'/../config/jsontoclassgenerator.php' => config_path('jsontoclassgenerator.php'),
45-
], 'jsontoclassgenerator.config');
44+
__DIR__.'/../config/dto-generator.php' => config_path('dto-generator.php'),
45+
], 'dto-generator.config');
4646

4747
}
4848
}

src/Services/AbstractClassGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator\Services;
3+
namespace TimeHunter\LaravelDTOGenerator\Services;
44

55

66
use Illuminate\Support\Facades\File;
@@ -24,7 +24,7 @@ abstract protected function getData(): array;
2424
*/
2525
public function generate()
2626
{
27-
$this->recursiveCreateFile($this->getData(), config('jsontoclassgenerator.namespace'));
27+
$this->recursiveCreateFile($this->getData(), config('dto-generator.namespace'));
2828
}
2929

3030
public function getType($value)
@@ -156,7 +156,7 @@ private function recursiveCreateFile($sample, $namespaceString)
156156

157157
$file = $className . '.php';
158158

159-
$location = config('jsontoclassgenerator.file_location') . '/' . $file;
159+
$location = config('dto-generator.file_location') . '/' . $file;
160160
File::put($location, $phpFile);
161161
}
162162
}

src/Services/ArrayToClassGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator\Services;
3+
namespace TimeHunter\LaravelDTOGenerator\Services;
44

55

66
/**
@@ -15,6 +15,6 @@ class ArrayToClassGenerator extends AbstractClassGenerator
1515
*/
1616
public function getData(): array
1717
{
18-
return config('jsontoclassgenerator.array');
18+
return config('dto-generator.array');
1919
}
2020
}

src/Services/JsonToClassGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TimeHunter\LaravelJsonToClassGenerator\Services;
3+
namespace TimeHunter\LaravelDTOGenerator\Services;
44

55

66
use Illuminate\Support\Facades\File;
@@ -18,7 +18,7 @@ class JsonToClassGenerator extends AbstractClassGenerator
1818
*/
1919
public function getData(): array
2020
{
21-
return json_decode(config('jsontoclassgenerator.json'),1);
21+
return json_decode(config('dto-generator.json'),1);
2222
}
2323

2424
}

0 commit comments

Comments
 (0)