Conditions | 4 |
Paths | 6 |
Total Lines | 67 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
29 | public function runActualTask($params = []) |
||
30 | { |
||
31 | //project composer.json |
||
32 | // - app/src/... |
||
33 | // - app2/src/... |
||
34 | // DO FOR BOTH |
||
35 | //module composor.json |
||
36 | // ONLY FOR module |
||
37 | $listOfAutoLoads = []; |
||
|
|||
38 | $baseCommands = ' |
||
39 | if(! isset($data["autoload"])) { |
||
40 | $data["autoload"] = []; |
||
41 | } |
||
42 | if(! isset($data["autoload"]["psr-4"])) { |
||
43 | $data["autoload"]["psr-4"] = []; |
||
44 | } |
||
45 | '; |
||
46 | $addPage = ''; |
||
47 | if ($this->mu()->getIsModuleUpgrade()) { |
||
48 | $addPage = ' |
||
49 | if(! isset($data["autoload"]["files"])) { |
||
50 | $data["autoload"]["files"] = [ |
||
51 | "app/src/Page.php", |
||
52 | "app/src/PageController.php" |
||
53 | ]; |
||
54 | }'; |
||
55 | } |
||
56 | |||
57 | $codeDirs = $this->mu()->findNameSpaceAndCodeDirs(); |
||
58 | $webRootLocation = $this->mu()->getWebRootDirLocation(); |
||
59 | $command = $baseCommands . $addPage; |
||
60 | $comment = 'Adding autoload Page and Page controller details in ' . $webRootLocation . '/composer.json'; |
||
61 | $this->updateJSONViaCommandLine( |
||
62 | $webRootLocation, |
||
63 | $command, |
||
64 | $comment |
||
65 | ); |
||
66 | foreach ($codeDirs as $baseNameSpace => $codeDir) { |
||
67 | $location = trim(str_replace($webRootLocation, '', $codeDir), '/') . '/'; |
||
68 | //update webroot composer file |
||
69 | //location: |
||
70 | $command = $baseCommands . ' |
||
71 | $data["autoload"]["psr-4"]["' . $this->doubleSlash($baseNameSpace) . '"] = "' . $location . '";'; |
||
72 | $comment = 'Adding autoload psr-4 details in ' . $webRootLocation . '/composer.json: ' . $baseNameSpace . ' => ' . $location; |
||
73 | $this->updateJSONViaCommandLine( |
||
74 | $webRootLocation, |
||
75 | $command, |
||
76 | $comment |
||
77 | ); |
||
78 | if ($this->mu()->getIsModuleUpgrade()) { |
||
79 | $moduleLocation = dirname($codeDir); |
||
80 | $location = trim(basename($codeDir), '/') . '/'; |
||
81 | $command = $baseCommands . ' |
||
82 | $data["autoload"]["psr-4"]["' . $this->doubleSlash($baseNameSpace) . '"] = "' . ltrim($location, '/') . '";'; |
||
83 | $comment = 'Adding autoload psr-4 details in ' . $moduleLocation . '/composer.json: ' . $baseNameSpace . ' => ' . $location; |
||
84 | $this->updateJSONViaCommandLine( |
||
85 | $moduleLocation, |
||
86 | $command, |
||
87 | $comment |
||
88 | ); |
||
89 | } |
||
90 | } |
||
91 | $this->mu()->execMe( |
||
92 | $this->mu()->getWebRootDirLocation(), |
||
93 | 'composer dumpautoload', |
||
94 | 'run composer dumpautoload', |
||
95 | false |
||
96 | ); |
||
109 |