| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| Code Lines | 38 |
| 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 |
||
| 34 | public function stringProvider() { |
||
| 35 | return [ |
||
| 36 | [ |
||
| 37 | 'value' => null, |
||
| 38 | 'options' => [], |
||
| 39 | 'expectedErrors' => Error::newError( 'Not a string' ) |
||
| 40 | ], |
||
| 41 | [ |
||
| 42 | 'value' => '', |
||
| 43 | 'options' => [], |
||
| 44 | 'expectedErrors' => null |
||
| 45 | ], |
||
| 46 | [ |
||
| 47 | 'value' => '', |
||
| 48 | 'options' => [ 'length' => 1 ], |
||
| 49 | 'expectedErrors' => Error::newError( 'Value exceeding lower bound', 'length' ) |
||
| 50 | ], |
||
| 51 | [ |
||
| 52 | 'value' => '1', |
||
| 53 | 'options' => [ 'length' => 1 ], |
||
| 54 | 'expectedErrors' => null |
||
| 55 | ], |
||
| 56 | [ |
||
| 57 | 'value' => '1', |
||
| 58 | 'options' => [ 'length' => 0 ], |
||
| 59 | 'expectedErrors' => Error::newError( 'Value exceeding upper bound', 'length' ) |
||
| 60 | ], |
||
| 61 | [ |
||
| 62 | 'value' => '', |
||
| 63 | 'options' => [ 'length' => 0 ], |
||
| 64 | 'expectedErrors' => null |
||
| 65 | ], |
||
| 66 | [ |
||
| 67 | 'value' => '', |
||
| 68 | 'options' => [ 'minlength' => 1 ], |
||
| 69 | 'expectedErrors' => Error::newError( 'Value exceeding lower bound', 'length' ) |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | 'value' => '1', |
||
| 73 | 'options' => [ 'minlength' => 1 ], |
||
| 74 | 'expectedErrors' => null |
||
| 75 | ], |
||
| 76 | [ |
||
| 77 | 'value' => '1', |
||
| 78 | 'options' => [ 'maxlength' => 0 ], |
||
| 79 | 'expectedErrors' => Error::newError( 'Value exceeding upper bound', 'length' ) |
||
| 80 | ], |
||
| 81 | [ |
||
| 82 | 'value' => '', |
||
| 83 | 'options' => [ 'maxlength' => 0 ], |
||
| 84 | 'expectedErrors' => null |
||
| 85 | ], |
||
| 86 | [ |
||
| 87 | 'value' => '1', |
||
| 88 | 'options' => [ 'regex' => '/^$/' ], |
||
| 89 | 'expectedErrors' => Error::newError( 'String does not match the regular expression /^$/' ) |
||
| 90 | ], |
||
| 91 | [ |
||
| 92 | 'value' => '', |
||
| 93 | 'options' => [ 'regex' => '/^$/' ], |
||
| 94 | 'expectedErrors' => null |
||
| 95 | ], |
||
| 96 | ]; |
||
| 97 | } |
||
| 98 | |||
| 100 |