| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 3 |
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 |
||
| 60 | public function schemaConstraintDataProvider() |
||
| 61 | { |
||
| 62 | return [ |
||
| 63 | 'choice-string' => [ |
||
| 64 | 'field' => 'choiceString', |
||
| 65 | 'acceptedValue' => 'a lo mejor', |
||
| 66 | 'rejectedValue' => 'no puedo', |
||
| 67 | 'errorMessage' => 'Does not have a value in the enumeration ["si","no","a lo mejor","mas"]' |
||
| 68 | ], |
||
| 69 | 'choice-integer' => [ |
||
| 70 | 'field' => 'choiceInteger', |
||
| 71 | 'acceptedValue' => 0, |
||
| 72 | 'rejectedValue' => 5, |
||
| 73 | 'errorMessage' => 'Does not have a value in the enumeration [0,1,2]' |
||
| 74 | ], |
||
| 75 | 'email' => [ |
||
| 76 | 'field' => 'email', |
||
| 77 | 'acceptedValue' => '[email protected]', |
||
| 78 | 'rejectedValue' => 'invalidemail@sss.', |
||
| 79 | 'errorMessage' => 'Invalid email' |
||
| 80 | ], |
||
| 81 | 'url' => [ |
||
| 82 | 'field' => 'url', |
||
| 83 | 'acceptedValue' => 'https://github.com/libgraviton/graviton', |
||
| 84 | 'rejectedValue' => 'jjj--no-url', |
||
| 85 | 'errorMessage' => 'Invalid URL format' |
||
| 86 | ], |
||
| 87 | 'range-integer-lower-bound' => [ |
||
| 88 | 'field' => 'rangeInteger', |
||
| 89 | 'acceptedValue' => 5, |
||
| 90 | 'rejectedValue' => 4, |
||
| 91 | 'errorMessage' => 'Must have a minimum value of 5' |
||
| 92 | ], |
||
| 93 | 'range-integer-upper-bound' => [ |
||
| 94 | 'field' => 'rangeInteger', |
||
| 95 | 'acceptedValue' => 9, |
||
| 96 | 'rejectedValue' => 10, |
||
| 97 | 'errorMessage' => 'Must have a maximum value of 9' |
||
| 98 | ], |
||
| 99 | 'range-double-lower-bound' => [ |
||
| 100 | 'field' => 'rangeDouble', |
||
| 101 | 'acceptedValue' => 0.0, |
||
| 102 | 'rejectedValue' => -0.1, |
||
| 103 | 'errorMessage' => 'Must have a minimum value of 0' |
||
| 104 | ], |
||
| 105 | 'range-double-upper-bound' => [ |
||
| 106 | 'field' => 'rangeDouble', |
||
| 107 | 'acceptedValue' => 0.99, |
||
| 108 | 'rejectedValue' => 1.11, |
||
| 109 | 'errorMessage' => 'Must have a maximum value of 1' |
||
| 110 | ] |
||
| 111 | ]; |
||
| 112 | } |
||
| 113 | } |
||
| 114 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.