Conditions | 11 |
Paths | 6 |
Total Lines | 22 |
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 |
||
20 | public static function getFactory($endpoint) |
||
21 | { |
||
22 | $endpoint = static::cleanEndpoint($endpoint); |
||
23 | |||
24 | switch ($endpoint) { |
||
25 | case (preg_match('/^(\/|)contact_lists(\/{1}[\w\{\}]*|)$/', $endpoint) ? $endpoint : !$endpoint): |
||
26 | return '\\Mailxpert\\Model\\ContactListFactory'; |
||
27 | case (preg_match('/^(\/|)contacts(\/{1}[\w\{\}]*|)$/', $endpoint) ? $endpoint : !$endpoint): |
||
28 | return '\\Mailxpert\\Model\\ContactFactory'; |
||
29 | case (preg_match('/^(\/|)segments(\/{1}[\w\{\}]*|)$/', $endpoint) ? $endpoint : !$endpoint): |
||
30 | return '\\Mailxpert\\Model\\SegmentFactory'; |
||
31 | case (preg_match('/^(\/|)custom_fields(\/{1}[\w\{\}]*|)$/', $endpoint) ? $endpoint : !$endpoint): |
||
32 | return '\\Mailxpert\\Model\\CustomFieldFactory'; |
||
33 | case (preg_match( |
||
34 | '/^(\/|)custom_fields(\/{1}[\w\{\}]*|)\/choices(\/{1}[\w\{\}]*|)$/', |
||
35 | $endpoint |
||
36 | ) ? $endpoint : !$endpoint): |
||
37 | return '\\Mailxpert\\Model\\CustomFieldChoiceFactory'; |
||
38 | default: |
||
39 | throw new MailxpertSDKException(sprintf('No model found for endpoint %s', $endpoint)); |
||
40 | } |
||
41 | } |
||
42 | |||
79 |