| Conditions | 1 |
| Paths | 1 |
| Total Lines | 87 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 | |||
| 88 | // Range |
||
| 89 | |||
| 90 | 'range-integer-lower-bound' => [ |
||
| 91 | 'field' => 'rangeInteger', |
||
| 92 | 'acceptedValue' => 5, |
||
| 93 | 'rejectedValue' => 4, |
||
| 94 | 'errorMessage' => 'Must have a minimum value of 5' |
||
| 95 | ], |
||
| 96 | 'range-integer-upper-bound' => [ |
||
| 97 | 'field' => 'rangeInteger', |
||
| 98 | 'acceptedValue' => 9, |
||
| 99 | 'rejectedValue' => 10, |
||
| 100 | 'errorMessage' => 'Must have a maximum value of 9' |
||
| 101 | ], |
||
| 102 | 'range-double-lower-bound' => [ |
||
| 103 | 'field' => 'rangeDouble', |
||
| 104 | 'acceptedValue' => 0.0, |
||
| 105 | 'rejectedValue' => -0.0001, |
||
| 106 | 'errorMessage' => 'Must have a minimum value of 0' |
||
| 107 | ], |
||
| 108 | 'range-double-upper-bound' => [ |
||
| 109 | 'field' => 'rangeDouble', |
||
| 110 | 'acceptedValue' => 1.0, |
||
| 111 | 'rejectedValue' => 1.0000001, |
||
| 112 | 'errorMessage' => 'Must have a maximum value of 1' |
||
| 113 | ], |
||
| 114 | |||
| 115 | // GreatherThanOrEqual |
||
| 116 | |||
| 117 | 'greaterthan-integer' => [ |
||
| 118 | 'field' => 'greaterThanOrEqualInt', |
||
| 119 | 'acceptedValue' => 0, |
||
| 120 | 'rejectedValue' => -1, |
||
| 121 | 'errorMessage' => 'Must have a minimum value of 0' |
||
| 122 | ], |
||
| 123 | 'greaterthan-double' => [ |
||
| 124 | 'field' => 'greaterThanOrEqualDouble', |
||
| 125 | 'acceptedValue' => 0.1, |
||
| 126 | 'rejectedValue' => 0, |
||
| 127 | 'errorMessage' => 'Must have a minimum value of 0.1' |
||
| 128 | ], |
||
| 129 | |||
| 130 | // LessThanOrEqual |
||
| 131 | |||
| 132 | 'lessthan-integer' => [ |
||
| 133 | 'field' => 'lessThanOrEqualInt', |
||
| 134 | 'acceptedValue' => 0, |
||
| 135 | 'rejectedValue' => 1, |
||
| 136 | 'errorMessage' => 'Must have a maximum value of 0' |
||
| 137 | ], |
||
| 138 | 'lessthan-double' => [ |
||
| 139 | 'field' => 'lessThanOrEqualDouble', |
||
| 140 | 'acceptedValue' => 0.1, |
||
| 141 | 'rejectedValue' => 0.1000001, |
||
| 142 | 'errorMessage' => 'Must have a maximum value of 0.1' |
||
| 143 | ] |
||
| 144 | |||
| 145 | ]; |
||
| 146 | } |
||
| 147 | } |
||
| 148 |
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.