| Conditions | 1 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 49 |
| 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 |
||
| 16 | public function dataOptions(): array |
||
| 17 | { |
||
| 18 | return [ |
||
| 19 | [ |
||
| 20 | new Url(), |
||
| 21 | [ |
||
| 22 | 'pattern' => '/^((?i)http|https):\/\/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+)(?::\d{1,5})?([?\/#].*$|$)/', |
||
| 23 | 'validSchemes' => ['http', 'https'], |
||
| 24 | 'enableIDN' => false, |
||
| 25 | 'incorrectInputMessage' => [ |
||
| 26 | 'template' => 'The value must have a string type.', |
||
| 27 | 'parameters' => [], |
||
| 28 | ], |
||
| 29 | 'message' => [ |
||
| 30 | 'template' => 'This value is not a valid URL.', |
||
| 31 | 'parameters' => [], |
||
| 32 | ], |
||
| 33 | 'skipOnEmpty' => false, |
||
| 34 | 'skipOnError' => false, |
||
| 35 | ], |
||
| 36 | ], |
||
| 37 | [ |
||
| 38 | new Url(enableIDN: true), |
||
| 39 | [ |
||
| 40 | 'pattern' => '/^((?i)http|https):\/\/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+)(?::\d{1,5})?([?\/#].*$|$)/', |
||
| 41 | 'validSchemes' => ['http', 'https'], |
||
| 42 | 'enableIDN' => true, |
||
| 43 | 'incorrectInputMessage' => [ |
||
| 44 | 'template' => 'The value must have a string type.', |
||
| 45 | 'parameters' => [], |
||
| 46 | ], |
||
| 47 | 'message' => [ |
||
| 48 | 'template' => 'This value is not a valid URL.', |
||
| 49 | 'parameters' => [], |
||
| 50 | ], |
||
| 51 | 'skipOnEmpty' => false, |
||
| 52 | 'skipOnError' => false, |
||
| 53 | ], |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | new Url(validSchemes: ['http']), |
||
| 57 | [ |
||
| 58 | 'pattern' => '/^((?i)http):\/\/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+)(?::\d{1,5})?([?\/#].*$|$)/', |
||
| 59 | 'validSchemes' => ['http'], |
||
| 60 | 'enableIDN' => false, |
||
| 61 | 'incorrectInputMessage' => [ |
||
| 62 | 'template' => 'The value must have a string type.', |
||
| 63 | 'parameters' => [], |
||
| 64 | ], |
||
| 65 | 'message' => [ |
||
| 66 | 'template' => 'This value is not a valid URL.', |
||
| 67 | 'parameters' => [], |
||
| 68 | ], |
||
| 69 | 'skipOnEmpty' => false, |
||
| 70 | 'skipOnError' => false, |
||
| 71 | ], |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | new Url(pattern: '/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+).*$/', enableIDN: true), |
||
| 75 | [ |
||
| 76 | 'pattern' => '/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+).*$/', |
||
| 77 | 'validSchemes' => ['http', 'https'], |
||
| 78 | 'enableIDN' => true, |
||
| 79 | 'incorrectInputMessage' => [ |
||
| 80 | 'template' => 'The value must have a string type.', |
||
| 81 | 'parameters' => [], |
||
| 82 | ], |
||
| 83 | 'message' => [ |
||
| 84 | 'template' => 'This value is not a valid URL.', |
||
| 85 | 'parameters' => [], |
||
| 86 | ], |
||
| 87 | 'skipOnEmpty' => false, |
||
| 88 | 'skipOnError' => false, |
||
| 89 | ], |
||
| 196 |