33namespace BinaryCats \Exportify \Commands ;
44
55use Illuminate \Console \GeneratorCommand ;
6- use Illuminate \Support \Str ;
76use Illuminate \Support \Facades \File ;
7+ use Illuminate \Support \Str ;
88use Symfony \Component \Console \Input \InputOption ;
99
1010class MakeExportCommand extends GeneratorCommand
@@ -39,7 +39,7 @@ public function handle(): int
3939 $ dryRun = $ this ->option ('dry-run ' );
4040
4141 $ files = [
42- $ this ->getPath ($ this ->qualifyClass ($ name ))
42+ $ this ->getPath ($ this ->qualifyClass ($ name )),
4343 ];
4444
4545 // Create factory if requested
@@ -84,44 +84,44 @@ public function handle(): int
8484 */
8585 protected function getStub (): string
8686 {
87- return __DIR__ . '/../../stubs/exportable.stub ' ;
87+ return __DIR__ . '/../../stubs/exportable.stub ' ;
8888 }
8989
9090 /**
9191 * Get the default namespace for the class.
9292 */
9393 protected function getDefaultNamespace ($ rootNamespace ): string
9494 {
95- return $ rootNamespace . '\\Exports ' ;
95+ return $ rootNamespace. '\\Exports ' ;
9696 }
9797
9898 /**
9999 * Create the factory class
100100 */
101101 protected function createFactory (string $ name , bool $ dryRun ): string
102102 {
103- $ className = Str::studly ($ name ) . 'ExportFactory ' ;
104- $ namespace = $ this ->rootNamespace () . 'ExportFactories ' ;
105- $ path = $ this ->getPath ($ namespace . '\\' . $ className );
103+ $ className = Str::studly ($ name ). 'ExportFactory ' ;
104+ $ namespace = $ this ->rootNamespace (). 'ExportFactories ' ;
105+ $ path = $ this ->getPath ($ namespace. '\\' . $ className );
106106
107- if (!$ dryRun ) {
107+ if (! $ dryRun ) {
108108 $ this ->ensureDirectoryExists (dirname ($ path ));
109- $ stub = File::get (__DIR__ . '/../../stubs/exportable_factory.stub ' );
110- $ exportClass = Str::studly ($ name ) . 'Export ' ;
109+ $ stub = File::get (__DIR__ . '/../../stubs/exportable_factory.stub ' );
110+ $ exportClass = Str::studly ($ name ). 'Export ' ;
111111 $ content = str_replace (
112112 [
113113 '{{ namespace }} ' ,
114114 '{{ class }} ' ,
115115 '{{ exportableNamespace }} ' ,
116116 '{{ exportableClass }} ' ,
117- '{{ livewireClass }} '
117+ '{{ livewireClass }} ' ,
118118 ],
119119 [
120120 $ namespace ,
121121 $ className ,
122- $ this ->rootNamespace () . 'Exports ' ,
122+ $ this ->rootNamespace (). 'Exports ' ,
123123 $ exportClass ,
124- 'Export ' . Str::studly ($ name )
124+ 'Export ' . Str::studly ($ name ),
125125 ],
126126 $ stub
127127 );
@@ -136,26 +136,26 @@ protected function createFactory(string $name, bool $dryRun): string
136136 */
137137 protected function createPolicy (string $ name , bool $ dryRun ): string
138138 {
139- $ className = Str::studly ($ name ) . 'ExportPolicy ' ;
140- $ namespace = $ this ->rootNamespace () . 'Policies ' ;
141- $ path = $ this ->getPath ($ namespace . '\\' . $ className );
139+ $ className = Str::studly ($ name ). 'ExportPolicy ' ;
140+ $ namespace = $ this ->rootNamespace (). 'Policies ' ;
141+ $ path = $ this ->getPath ($ namespace. '\\' . $ className );
142142
143- if (!$ dryRun ) {
143+ if (! $ dryRun ) {
144144 $ this ->ensureDirectoryExists (dirname ($ path ));
145- $ stub = File::get (__DIR__ . '/../../stubs/exportable_policy.stub ' );
146- $ exportClass = Str::studly ($ name ) . 'Export ' ;
145+ $ stub = File::get (__DIR__ . '/../../stubs/exportable_policy.stub ' );
146+ $ exportClass = Str::studly ($ name ). 'Export ' ;
147147 $ content = str_replace (
148148 [
149149 '{{ namespace }} ' ,
150150 '{{ class }} ' ,
151151 '{{ exportableNamespace }} ' ,
152- '{{ exportableClass }} '
152+ '{{ exportableClass }} ' ,
153153 ],
154154 [
155155 $ namespace ,
156156 $ className ,
157- $ this ->rootNamespace () . 'Exports ' ,
158- $ exportClass
157+ $ this ->rootNamespace (). 'Exports ' ,
158+ $ exportClass,
159159 ],
160160 $ stub
161161 );
@@ -170,36 +170,36 @@ protected function createPolicy(string $name, bool $dryRun): string
170170 */
171171 protected function createLivewire (string $ name , bool $ dryRun ): string
172172 {
173- $ className = 'Export ' . Str::studly ($ name );
174- $ namespace = $ this ->rootNamespace () . 'Livewire ' ;
175- $ path = $ this ->getPath ($ namespace . '\\' . $ className );
176- $ viewName = 'export- ' . Str::kebab ($ name );
173+ $ className = 'Export ' . Str::studly ($ name );
174+ $ namespace = $ this ->rootNamespace (). 'Livewire ' ;
175+ $ path = $ this ->getPath ($ namespace. '\\' . $ className );
176+ $ viewName = 'export- ' . Str::kebab ($ name );
177177
178- if (!$ dryRun ) {
178+ if (! $ dryRun ) {
179179 $ this ->ensureDirectoryExists (dirname ($ path ));
180- $ stub = File::get (__DIR__ . '/../../stubs/exportable_livewire.stub ' );
181- $ factoryClass = Str::studly ($ name ) . 'ExportFactory ' ;
180+ $ stub = File::get (__DIR__ . '/../../stubs/exportable_livewire.stub ' );
181+ $ factoryClass = Str::studly ($ name ). 'ExportFactory ' ;
182182 $ content = str_replace (
183183 [
184184 '{{ namespace }} ' ,
185185 '{{ class }} ' ,
186186 '{{ factoryNamespace }} ' ,
187187 '{{ factoryClass }} ' ,
188- '{{ view }} '
188+ '{{ view }} ' ,
189189 ],
190190 [
191191 $ namespace ,
192192 $ className ,
193- $ this ->rootNamespace () . 'ExportFactories ' ,
193+ $ this ->rootNamespace (). 'ExportFactories ' ,
194194 $ factoryClass ,
195- $ viewName
195+ $ viewName,
196196 ],
197197 $ stub
198198 );
199199 File::put ($ path , $ content );
200200
201201 // Create the view file
202- $ viewPath = resource_path ('views/livewire/ ' . $ viewName . '.blade.php ' );
202+ $ viewPath = resource_path ('views/livewire/ ' . $ viewName. '.blade.php ' );
203203 $ this ->ensureDirectoryExists (dirname ($ viewPath ));
204204 File::put ($ viewPath , '<div><!-- TODO: Implement export view --></div> ' );
205205 }
@@ -223,13 +223,13 @@ protected function createTests(string $name, array $files, bool $dryRun): array
223223 default => 'exportable_livewire '
224224 };
225225
226- $ testClassName = $ className . 'Test ' ;
227- $ testPath = base_path ('tests/Feature/ ' . str_replace ('app/ ' , '' , dirname ($ file )) . '/ ' . $ testClassName . '.php ' );
228- $ testNamespace = 'Tests \\Feature \\' . str_replace ('/ ' , '\\' , str_replace ('app/ ' , '' , dirname ($ file )));
226+ $ testClassName = $ className. 'Test ' ;
227+ $ testPath = base_path ('tests/Feature/ ' . str_replace ('app/ ' , '' , dirname ($ file )). '/ ' . $ testClassName. '.php ' );
228+ $ testNamespace = 'Tests \\Feature \\' . str_replace ('/ ' , '\\' , str_replace ('app/ ' , '' , dirname ($ file )));
229229
230- if (!$ dryRun ) {
230+ if (! $ dryRun ) {
231231 $ this ->ensureDirectoryExists (dirname ($ testPath ));
232- $ stub = File::get (__DIR__ . '/../../stubs/ ' . $ type . '_test.stub ' );
232+ $ stub = File::get (__DIR__ . '/../../stubs/ ' . $ type. '_test.stub ' );
233233
234234 $ replacements = [
235235 '{{ namespace }} ' => $ testNamespace ,
@@ -239,25 +239,25 @@ protected function createTests(string $name, array $files, bool $dryRun): array
239239 // Add specific replacements based on type
240240 switch ($ type ) {
241241 case 'exportable ' :
242- $ replacements ['{{ exportableNamespace }} ' ] = $ this ->rootNamespace () . 'Exports ' ;
243- $ replacements ['{{ exportableClass }} ' ] = Str::studly ($ name ) . 'Export ' ;
242+ $ replacements ['{{ exportableNamespace }} ' ] = $ this ->rootNamespace (). 'Exports ' ;
243+ $ replacements ['{{ exportableClass }} ' ] = Str::studly ($ name ). 'Export ' ;
244244 break ;
245245 case 'exportable_factory ' :
246- $ replacements ['{{ factoryNamespace }} ' ] = $ this ->rootNamespace () . 'ExportFactories ' ;
247- $ replacements ['{{ factoryClass }} ' ] = Str::studly ($ name ) . 'ExportFactory ' ;
246+ $ replacements ['{{ factoryNamespace }} ' ] = $ this ->rootNamespace (). 'ExportFactories ' ;
247+ $ replacements ['{{ factoryClass }} ' ] = Str::studly ($ name ). 'ExportFactory ' ;
248248 break ;
249249 case 'exportable_policy ' :
250- $ replacements ['{{ policyNamespace }} ' ] = $ this ->rootNamespace () . 'Policies ' ;
251- $ replacements ['{{ policyClass }} ' ] = Str::studly ($ name ) . 'ExportPolicy ' ;
252- $ replacements ['{{ exportableNamespace }} ' ] = $ this ->rootNamespace () . 'Exports ' ;
253- $ replacements ['{{ exportableClass }} ' ] = Str::studly ($ name ) . 'Export ' ;
250+ $ replacements ['{{ policyNamespace }} ' ] = $ this ->rootNamespace (). 'Policies ' ;
251+ $ replacements ['{{ policyClass }} ' ] = Str::studly ($ name ). 'ExportPolicy ' ;
252+ $ replacements ['{{ exportableNamespace }} ' ] = $ this ->rootNamespace (). 'Exports ' ;
253+ $ replacements ['{{ exportableClass }} ' ] = Str::studly ($ name ). 'Export ' ;
254254 break ;
255255 case 'exportable_livewire ' :
256- $ replacements ['{{ livewireNamespace }} ' ] = $ this ->rootNamespace () . 'Livewire ' ;
257- $ replacements ['{{ livewireClass }} ' ] = 'Export ' . Str::studly ($ name );
258- $ replacements ['{{ factoryNamespace }} ' ] = $ this ->rootNamespace () . 'ExportFactories ' ;
259- $ replacements ['{{ factoryClass }} ' ] = Str::studly ($ name ) . 'ExportFactory ' ;
260- $ replacements ['{{ view }} ' ] = 'export- ' . Str::kebab ($ name );
256+ $ replacements ['{{ livewireNamespace }} ' ] = $ this ->rootNamespace (). 'Livewire ' ;
257+ $ replacements ['{{ livewireClass }} ' ] = 'Export ' . Str::studly ($ name );
258+ $ replacements ['{{ factoryNamespace }} ' ] = $ this ->rootNamespace (). 'ExportFactories ' ;
259+ $ replacements ['{{ factoryClass }} ' ] = Str::studly ($ name ). 'ExportFactory ' ;
260+ $ replacements ['{{ view }} ' ] = 'export- ' . Str::kebab ($ name );
261261 break ;
262262 }
263263
@@ -294,8 +294,8 @@ protected function getOptions(): array
294294 */
295295 protected function ensureDirectoryExists (string $ path ): void
296296 {
297- if (!File::isDirectory ($ path )) {
297+ if (! File::isDirectory ($ path )) {
298298 File::makeDirectory ($ path , 0755 , true );
299299 }
300300 }
301- }
301+ }
0 commit comments