| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| 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 |
||
| 171 | protected function createContentType() |
||
| 172 | { |
||
| 173 | $createStruct = new Content\Type\CreateStruct( |
||
| 174 | [ |
||
| 175 | 'name' => [ |
||
| 176 | 'eng-US' => 'Test', |
||
| 177 | 'ger-DE' => 'Test NOR', |
||
| 178 | ], |
||
| 179 | 'identifier' => 'test-' . $this->getTypeName(), |
||
| 180 | 'status' => 0, |
||
| 181 | 'creatorId' => 14, |
||
| 182 | 'created' => time(), |
||
| 183 | 'modifierId' => 14, |
||
| 184 | 'modified' => time(), |
||
| 185 | 'initialLanguageId' => 2, |
||
| 186 | 'remoteId' => 'abcdef', |
||
| 187 | ] |
||
| 188 | ); |
||
| 189 | |||
| 190 | $createStruct->fieldDefinitions = array( |
||
| 191 | new Content\Type\FieldDefinition( |
||
| 192 | [ |
||
| 193 | 'name' => [ |
||
| 194 | 'eng-US' => 'Name', |
||
| 195 | 'ger-DE' => 'Name NOR', |
||
| 196 | ], |
||
| 197 | 'identifier' => 'name', |
||
| 198 | 'fieldGroup' => 'main', |
||
| 199 | 'position' => 1, |
||
| 200 | 'fieldType' => 'ezstring', |
||
| 201 | 'isTranslatable' => false, |
||
| 202 | 'isRequired' => true, |
||
| 203 | 'mainLanguageCode' => 'eng-US', |
||
| 204 | ] |
||
| 205 | ), |
||
| 206 | new Content\Type\FieldDefinition( |
||
| 207 | [ |
||
| 208 | 'name' => [ |
||
| 209 | 'eng-US' => 'Data', |
||
| 210 | 'ger-DE' => 'Data NOR', |
||
| 211 | ], |
||
| 212 | 'identifier' => 'data', |
||
| 213 | 'fieldGroup' => 'main', |
||
| 214 | 'position' => 2, |
||
| 215 | 'fieldType' => $this->getTypeName(), |
||
| 216 | 'isTranslatable' => false, |
||
| 217 | 'isRequired' => true, |
||
| 218 | 'fieldTypeConstraints' => $this->getTypeConstraints(), |
||
| 219 | 'mainLanguageCode' => 'eng-US', |
||
| 220 | ] |
||
| 221 | ), |
||
| 222 | ); |
||
| 223 | |||
| 224 | $handler = $this->getCustomHandler(); |
||
| 225 | $contentTypeHandler = $handler->contentTypeHandler(); |
||
| 226 | |||
| 227 | return $contentTypeHandler->create($createStruct); |
||
| 228 | } |
||
| 229 | } |
||
| 230 |