| Conditions | 1 |
| Paths | 1 |
| Total Lines | 114 |
| Code Lines | 81 |
| 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 dataOptions(): array |
||
| 35 | { |
||
| 36 | return [ |
||
| 37 | [ |
||
| 38 | new Each([ |
||
| 39 | new Number(max: 13, pattern: '/1/'), |
||
| 40 | new Number(max: 14, pattern: '/2/'), |
||
| 41 | ]), |
||
| 42 | [ |
||
| 43 | 'incorrectInputMessage' => [ |
||
| 44 | 'template' => 'Value must be array or iterable.', |
||
| 45 | 'parameters' => [], |
||
| 46 | ], |
||
| 47 | 'incorrectInputKeyMessage' => [ |
||
| 48 | 'template' => 'Every iterable key must have an integer or a string type.', |
||
| 49 | 'parameters' => [], |
||
| 50 | ], |
||
| 51 | 'skipOnEmpty' => false, |
||
| 52 | 'skipOnError' => false, |
||
| 53 | 'rules' => [ |
||
| 54 | [ |
||
| 55 | 'number', |
||
| 56 | 'min' => null, |
||
| 57 | 'max' => 13, |
||
| 58 | 'incorrectInputMessage' => [ |
||
| 59 | 'template' => 'The allowed types are integer, float and string.', |
||
| 60 | 'parameters' => [], |
||
| 61 | ], |
||
| 62 | 'notNumberMessage' => [ |
||
| 63 | 'template' => 'Value must be a number.', |
||
| 64 | 'parameters' => [], |
||
| 65 | ], |
||
| 66 | 'lessThanMinMessage' => [ |
||
| 67 | 'template' => 'Value must be no less than {min}.', |
||
| 68 | 'parameters' => ['min' => null], |
||
| 69 | ], |
||
| 70 | 'greaterThanMaxMessage' => [ |
||
| 71 | 'template' => 'Value must be no greater than {max}.', |
||
| 72 | 'parameters' => ['max' => 13], |
||
| 73 | ], |
||
| 74 | 'skipOnEmpty' => false, |
||
| 75 | 'skipOnError' => false, |
||
| 76 | 'pattern' => '/1/', |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | 'number', |
||
| 80 | 'min' => null, |
||
| 81 | 'max' => 14, |
||
| 82 | 'incorrectInputMessage' => [ |
||
| 83 | 'template' => 'The allowed types are integer, float and string.', |
||
| 84 | 'parameters' => [], |
||
| 85 | ], |
||
| 86 | 'notNumberMessage' => [ |
||
| 87 | 'template' => 'Value must be a number.', |
||
| 88 | 'parameters' => [], |
||
| 89 | ], |
||
| 90 | 'lessThanMinMessage' => [ |
||
| 91 | 'template' => 'Value must be no less than {min}.', |
||
| 92 | 'parameters' => ['min' => null], |
||
| 93 | ], |
||
| 94 | 'greaterThanMaxMessage' => [ |
||
| 95 | 'template' => 'Value must be no greater than {max}.', |
||
| 96 | 'parameters' => ['max' => 14], |
||
| 97 | ], |
||
| 98 | 'skipOnEmpty' => false, |
||
| 99 | 'skipOnError' => false, |
||
| 100 | 'pattern' => '/2/', |
||
| 101 | ], |
||
| 102 | ], |
||
| 103 | ], |
||
| 104 | ], |
||
| 105 | 'rule without options' => [ |
||
| 106 | new Each([ |
||
| 107 | new Number(max: 13, pattern: '/1/'), |
||
| 108 | new RuleWithoutOptions(), |
||
| 109 | ]), |
||
| 110 | [ |
||
| 111 | 'incorrectInputMessage' => [ |
||
| 112 | 'template' => 'Value must be array or iterable.', |
||
| 113 | 'parameters' => [], |
||
| 114 | ], |
||
| 115 | 'incorrectInputKeyMessage' => [ |
||
| 116 | 'template' => 'Every iterable key must have an integer or a string type.', |
||
| 117 | 'parameters' => [], |
||
| 118 | ], |
||
| 119 | 'skipOnEmpty' => false, |
||
| 120 | 'skipOnError' => false, |
||
| 121 | 'rules' => [ |
||
| 122 | [ |
||
| 123 | 'number', |
||
| 124 | 'min' => null, |
||
| 125 | 'max' => 13, |
||
| 126 | 'incorrectInputMessage' => [ |
||
| 127 | 'template' => 'The allowed types are integer, float and string.', |
||
| 128 | 'parameters' => [], |
||
| 129 | ], |
||
| 130 | 'notNumberMessage' => [ |
||
| 131 | 'template' => 'Value must be a number.', |
||
| 132 | 'parameters' => [], |
||
| 133 | ], |
||
| 134 | 'lessThanMinMessage' => [ |
||
| 135 | 'template' => 'Value must be no less than {min}.', |
||
| 136 | 'parameters' => ['min' => null], |
||
| 137 | ], |
||
| 138 | 'greaterThanMaxMessage' => [ |
||
| 139 | 'template' => 'Value must be no greater than {max}.', |
||
| 140 | 'parameters' => ['max' => 13], |
||
| 141 | ], |
||
| 142 | 'skipOnEmpty' => false, |
||
| 143 | 'skipOnError' => false, |
||
| 144 | 'pattern' => '/1/', |
||
| 145 | ], |
||
| 146 | [ |
||
| 147 | 'test', |
||
| 148 | ], |
||
| 298 |