Conditions | 10 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
82 | private function dropAndCreate(string $drop, string $create, string $dropCreated, |
||
83 | string $test, string $dropTest, string $oldName, string $newName): string |
||
84 | { |
||
85 | if ($oldName == '' && $newName == '') { |
||
86 | $this->executeQuery($drop); |
||
87 | return 'dropped'; |
||
88 | } |
||
89 | if ($oldName == '') { |
||
90 | $this->executeQuery($create); |
||
91 | return 'created'; |
||
92 | } |
||
93 | if ($oldName != $newName) { |
||
94 | $created = $this->driver->execute($create); |
||
95 | $dropped = $this->driver->execute($drop); |
||
96 | // $this->executeSavedQuery(!($created && $this->driver->execute($drop))); |
||
97 | if (!$dropped && $created) { |
||
98 | $this->driver->execute($dropCreated); |
||
99 | } |
||
100 | return 'altered'; |
||
101 | } |
||
102 | $this->executeSavedQuery(!($this->driver->execute($test) && |
||
103 | $this->driver->execute($dropTest) && |
||
104 | $this->driver->execute($drop) && $this->driver->execute($create))); |
||
105 | return 'altered'; |
||
106 | } |
||
108 |