1 | <?php |
||
15 | class MakeTransformer extends Command |
||
16 | { |
||
17 | /** |
||
18 | * The name and signature of the console command. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $signature = 'make:transformer |
||
23 | {name : The name of the transformer class} |
||
24 | {--model= : The namespace to the model being transformed}'; |
||
25 | |||
26 | /** |
||
27 | * The console command description. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $description = 'Create a new transformer class'; |
||
32 | |||
33 | /** |
||
34 | * The file system instance. |
||
35 | * |
||
36 | * @var Filesystem |
||
37 | */ |
||
38 | protected $files; |
||
39 | |||
40 | /** |
||
41 | * Create a new command instance. |
||
42 | * |
||
43 | * @param Filesystem $files |
||
44 | */ |
||
45 | public function __construct( Filesystem $files ) |
||
51 | |||
52 | /** |
||
53 | * Execute the console command. |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function handle() |
||
61 | |||
62 | /** |
||
63 | * Generate the transformer class. |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | protected function generateTransformer() |
||
81 | |||
82 | /** |
||
83 | * Build a transformers directory if one doesn't exist. |
||
84 | * |
||
85 | * @param string $path |
||
86 | * @return void |
||
87 | */ |
||
88 | protected function makeDirectory( string $path ) |
||
94 | |||
95 | /** |
||
96 | * Build the class with the given name. |
||
97 | * |
||
98 | * @param string $name |
||
99 | * @return string |
||
100 | */ |
||
101 | protected function makeClass( string $name ):string |
||
111 | |||
112 | /** |
||
113 | * Replace the namespace for the given stub. |
||
114 | * |
||
115 | * @param string $stub |
||
116 | * @return string |
||
117 | */ |
||
118 | protected function replaceNamespace( string $stub ):string |
||
126 | |||
127 | /** |
||
128 | * Replace the class name for the given stub. |
||
129 | * |
||
130 | * @param string $stub |
||
131 | * @param string $name |
||
132 | * @return string |
||
133 | */ |
||
134 | protected function replaceClass( string $stub, string $name ):string |
||
140 | |||
141 | /** |
||
142 | * Replace the class name for the given stub. |
||
143 | * |
||
144 | * @param string $stub |
||
145 | * @param string $name |
||
146 | * @return string |
||
147 | */ |
||
148 | protected function replaceModel( string $stub, string $name ):string |
||
159 | |||
160 | /** |
||
161 | * Get the class name for the transformer. |
||
162 | * |
||
163 | * @param string $name |
||
164 | * @return string |
||
165 | */ |
||
166 | protected function getModelNamespace( string $name ):string |
||
174 | |||
175 | /** |
||
176 | * Get the class name for the transformer. |
||
177 | * |
||
178 | * @param string $namespace |
||
179 | * @return string |
||
180 | */ |
||
181 | protected function getClassFromNamespace( string $namespace ):string |
||
185 | } |