Conditions | 10 |
Paths | 4 |
Total Lines | 40 |
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 |
||
97 | private function argumentsAreValid( |
||
98 | $newIndexName, |
||
99 | $oldIndexName, |
||
100 | $aliasName |
||
101 | ): bool { |
||
102 | if ($newIndexName === null || |
||
103 | !is_string($newIndexName) || |
||
104 | mb_strlen($newIndexName) === 0 |
||
105 | ) { |
||
106 | $this->output->writeln( |
||
107 | '<error>Argument new-index-name must be a non empty string.</error>' |
||
108 | ); |
||
109 | |||
110 | return false; |
||
111 | } |
||
112 | |||
113 | if ($oldIndexName === null || |
||
114 | !is_string($oldIndexName) || |
||
115 | mb_strlen($oldIndexName) === 0 |
||
116 | ) { |
||
117 | $this->output->writeln( |
||
118 | '<error>Argument old-index-name must be a non empty string.</error>' |
||
119 | ); |
||
120 | |||
121 | return false; |
||
122 | } |
||
123 | |||
124 | if ($aliasName === null || |
||
125 | !is_string($aliasName) || |
||
126 | mb_strlen($aliasName) === 0 |
||
127 | ) { |
||
128 | $this->output->writeln( |
||
129 | '<error>Argument alias-name must be a non empty string.</error>' |
||
130 | ); |
||
131 | |||
132 | return false; |
||
133 | } |
||
134 | |||
135 | return true; |
||
136 | } |
||
137 | } |
||
138 |