Conditions | 26 |
Paths | 1458 |
Total Lines | 101 |
Lines | 66 |
Ratio | 65.35 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php namespace Savannabits\JetstreamInertiaGenerator\Generators; |
||
49 | public function handle() |
||
50 | { |
||
51 | $force = $this->option('force'); |
||
52 | |||
53 | //TODO check if exists |
||
54 | //TODO make global for all generator |
||
55 | //TODO also with prefix |
||
56 | /*if(!empty($template = $this->option('template'))) { |
||
57 | $this->create = 'templates.'.$template.'.create'; |
||
58 | $this->edit = 'templates.'.$template.'.edit'; |
||
59 | $this->form = 'templates.'.$template.'.form'; |
||
60 | $this->formRight = 'templates.'.$template.'form-right'; |
||
61 | $this->formJs = 'templates.'.$template.'.form-js'; |
||
62 | }*/ |
||
63 | |||
64 | if(!empty($belongsToMany = $this->option('belongs-to-many'))) { |
||
65 | $this->setBelongToManyRelation($belongsToMany); |
||
66 | } |
||
67 | /*Make Create Form*/ |
||
68 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/CreateForm.vue'); |
||
69 | if ($this->alreadyExists($viewPath) && !$force) { |
||
70 | $this->error('File '.$viewPath.' already exists!'); |
||
71 | } else { |
||
72 | if ($this->alreadyExists($viewPath) && $force) { |
||
73 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
74 | $this->files->delete($viewPath); |
||
75 | } |
||
76 | $this->makeDirectory($viewPath); |
||
77 | $this->files->put($viewPath, $this->buildForm("create-form")); |
||
78 | $this->info('Generating '.$viewPath.' finished'); |
||
79 | } |
||
80 | /*Make Create Page*/ |
||
81 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/Create.vue'); |
||
82 | if ($this->alreadyExists($viewPath) && !$force) { |
||
83 | $this->error('File '.$viewPath.' already exists!'); |
||
84 | } else { |
||
85 | if ($this->alreadyExists($viewPath) && $force) { |
||
86 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
87 | $this->files->delete($viewPath); |
||
88 | } |
||
89 | $this->makeDirectory($viewPath); |
||
90 | $this->files->put($viewPath, $this->buildForm("create")); |
||
91 | $this->info('Generating '.$viewPath.' finished'); |
||
92 | } |
||
93 | //Make edit form |
||
94 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/EditForm.vue'); |
||
95 | if ($this->alreadyExists($viewPath) && !$force) { |
||
96 | $this->error('File '.$viewPath.' already exists!'); |
||
97 | } else { |
||
98 | if ($this->alreadyExists($viewPath) && $force) { |
||
99 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
100 | $this->files->delete($viewPath); |
||
101 | } |
||
102 | $this->makeDirectory($viewPath); |
||
103 | $this->files->put($viewPath, $this->buildForm("edit-form")); |
||
104 | $this->info('Generating '.$viewPath.' finished'); |
||
105 | } |
||
106 | |||
107 | //Make edit Page |
||
108 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/Edit.vue'); |
||
109 | if ($this->alreadyExists($viewPath) && !$force) { |
||
110 | $this->error('File '.$viewPath.' already exists!'); |
||
111 | } else { |
||
112 | if ($this->alreadyExists($viewPath) && $force) { |
||
113 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
114 | $this->files->delete($viewPath); |
||
115 | } |
||
116 | $this->makeDirectory($viewPath); |
||
117 | $this->files->put($viewPath, $this->buildForm("edit")); |
||
118 | $this->info('Generating '.$viewPath.' finished'); |
||
119 | } |
||
120 | |||
121 | // Make Show Form |
||
122 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/ShowForm.vue'); |
||
123 | if ($this->alreadyExists($viewPath) && !$force) { |
||
124 | $this->error('File '.$viewPath.' already exists!'); |
||
125 | } else { |
||
126 | if ($this->alreadyExists($viewPath) && $force) { |
||
127 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
128 | $this->files->delete($viewPath); |
||
129 | } |
||
130 | $this->makeDirectory($viewPath); |
||
131 | $this->files->put($viewPath, $this->buildForm("show-form")); |
||
132 | $this->info('Generating '.$viewPath.' finished'); |
||
133 | } |
||
134 | |||
135 | // Make Show Page |
||
136 | $viewPath = resource_path('js/Pages/'.$this->modelPlural.'/Show.vue'); |
||
137 | if ($this->alreadyExists($viewPath) && !$force) { |
||
138 | $this->error('File '.$viewPath.' already exists!'); |
||
139 | } else { |
||
140 | if ($this->alreadyExists($viewPath) && $force) { |
||
141 | $this->warn('File '.$viewPath.' already exists! File will be deleted.'); |
||
142 | $this->files->delete($viewPath); |
||
143 | } |
||
144 | $this->makeDirectory($viewPath); |
||
145 | $this->files->put($viewPath, $this->buildForm("show")); |
||
146 | $this->info('Generating '.$viewPath.' finished'); |
||
147 | } |
||
148 | |||
149 | } |
||
150 | |||
232 |