Conditions | 2 |
Paths | 2 |
Total Lines | 56 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
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 |
||
11 | public function generate() |
||
12 | { |
||
13 | $generatedFiles = []; |
||
14 | |||
15 | $routeProviderFile = $this->getPath("app/Providers/")."LaragenRouteServiceProvider.php"; |
||
16 | $backendAuthRouteFile = $this->getPath("routes/backend/")."auth.php"; |
||
17 | $webRouteFile = $this->getPath("routes/frontend/")."web.php"; |
||
18 | $backendWebRouteFile = $this->getPath("routes/backend/")."web.php"; |
||
19 | |||
20 | if(self::$initializeFlag++ == 0){ |
||
21 | $this->initializeFiles([ |
||
22 | $webRouteFile => "Route", |
||
23 | $backendAuthRouteFile => "Routes/Backend-auth", |
||
24 | $backendWebRouteFile => "Routes/Backend-web" |
||
25 | ]); |
||
26 | } |
||
27 | |||
28 | $this->initializeFiles([ |
||
29 | $routeProviderFile => "RouteServiceProvider", |
||
30 | ]); |
||
31 | |||
32 | $this->insertIntoFile( |
||
33 | $routeProviderFile, |
||
34 | $this->getStub('fragments/RouteMap'), |
||
35 | "\n".$this->getStub('fragments/RouteMapCode') |
||
36 | ); |
||
37 | |||
38 | $this->insertIntoFile( |
||
39 | $webRouteFile, |
||
40 | "<?php\n", |
||
41 | "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
||
42 | ); |
||
43 | |||
44 | $this->insertIntoFile( |
||
45 | $webRouteFile, |
||
46 | "/" . "* Insert your routes here */", |
||
47 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
||
48 | ); |
||
49 | |||
50 | $generatedFiles[] = $webRouteFile; |
||
51 | |||
52 | $this->insertIntoFile( |
||
53 | $backendWebRouteFile, |
||
54 | "<?php\n", |
||
55 | "use App\\Http\\Controllers\\Backend\\".$this->module->getModelName()."Controller;\n" |
||
56 | ); |
||
57 | |||
58 | $this->insertIntoFile( |
||
59 | $backendWebRouteFile, |
||
60 | "/" . "* Insert your routes here */", |
||
61 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
||
62 | ); |
||
63 | |||
64 | $generatedFiles[] = $backendWebRouteFile; |
||
65 | |||
66 | return $generatedFiles; |
||
67 | } |
||
69 |