| Conditions | 1 | 
| Total Lines | 160 | 
| 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 Composite([  | 
            ||
| 39 | new Number(max: 13, integerPattern: '/1/', numberPattern: '/1/'),  | 
            ||
| 40 | new Number(max: 14, integerPattern: '/2/', numberPattern: '/2/'),  | 
            ||
| 41 | ]),  | 
            ||
| 42 | [  | 
            ||
| 43 | 'skipOnEmpty' => false,  | 
            ||
| 44 | 'skipOnError' => false,  | 
            ||
| 45 | 'rules' => [  | 
            ||
| 46 | [  | 
            ||
| 47 | 'number',  | 
            ||
| 48 | 'asInteger' => false,  | 
            ||
| 49 | 'min' => null,  | 
            ||
| 50 | 'max' => 13,  | 
            ||
| 51 | 'incorrectInputMessage' => [  | 
            ||
| 52 | 'template' => 'The allowed types are integer, float and string.',  | 
            ||
| 53 | 'parameters' => [],  | 
            ||
| 54 | ],  | 
            ||
| 55 | 'notNumberMessage' => [  | 
            ||
| 56 | 'template' => 'Value must be a number.',  | 
            ||
| 57 | 'parameters' => [],  | 
            ||
| 58 | ],  | 
            ||
| 59 | 'tooSmallMessage' => [  | 
            ||
| 60 |                                 'template' => 'Value must be no less than {min}.', | 
            ||
| 61 | 'parameters' => ['min' => null],  | 
            ||
| 62 | ],  | 
            ||
| 63 | 'tooBigMessage' => [  | 
            ||
| 64 |                                 'template' => 'Value must be no greater than {max}.', | 
            ||
| 65 | 'parameters' => ['max' => 13],  | 
            ||
| 66 | ],  | 
            ||
| 67 | 'skipOnEmpty' => false,  | 
            ||
| 68 | 'skipOnError' => false,  | 
            ||
| 69 | 'integerPattern' => '/1/',  | 
            ||
| 70 | 'numberPattern' => '/1/',  | 
            ||
| 71 | ],  | 
            ||
| 72 | [  | 
            ||
| 73 | 'number',  | 
            ||
| 74 | 'asInteger' => false,  | 
            ||
| 75 | 'min' => null,  | 
            ||
| 76 | 'max' => 14,  | 
            ||
| 77 | 'incorrectInputMessage' => [  | 
            ||
| 78 | 'template' => 'The allowed types are integer, float and string.',  | 
            ||
| 79 | 'parameters' => [],  | 
            ||
| 80 | ],  | 
            ||
| 81 | 'notNumberMessage' => [  | 
            ||
| 82 | 'template' => 'Value must be a number.',  | 
            ||
| 83 | 'parameters' => [],  | 
            ||
| 84 | ],  | 
            ||
| 85 | 'tooSmallMessage' => [  | 
            ||
| 86 |                                 'template' => 'Value must be no less than {min}.', | 
            ||
| 87 | 'parameters' => ['min' => null],  | 
            ||
| 88 | ],  | 
            ||
| 89 | 'tooBigMessage' => [  | 
            ||
| 90 |                                 'template' => 'Value must be no greater than {max}.', | 
            ||
| 91 | 'parameters' => ['max' => 14],  | 
            ||
| 92 | ],  | 
            ||
| 93 | 'skipOnEmpty' => false,  | 
            ||
| 94 | 'skipOnError' => false,  | 
            ||
| 95 | 'integerPattern' => '/2/',  | 
            ||
| 96 | 'numberPattern' => '/2/',  | 
            ||
| 97 | ],  | 
            ||
| 98 | ],  | 
            ||
| 99 | ],  | 
            ||
| 100 | ],  | 
            ||
| 101 | 'rule without options' => [  | 
            ||
| 102 | new Composite([  | 
            ||
| 103 | new Number(max: 13, integerPattern: '/1/', numberPattern: '/1/'),  | 
            ||
| 104 | new RuleWithoutOptions(),  | 
            ||
| 105 | ]),  | 
            ||
| 106 | [  | 
            ||
| 107 | 'skipOnEmpty' => false,  | 
            ||
| 108 | 'skipOnError' => false,  | 
            ||
| 109 | 'rules' => [  | 
            ||
| 110 | [  | 
            ||
| 111 | 'number',  | 
            ||
| 112 | 'asInteger' => false,  | 
            ||
| 113 | 'min' => null,  | 
            ||
| 114 | 'max' => 13,  | 
            ||
| 115 | 'incorrectInputMessage' => [  | 
            ||
| 116 | 'template' => 'The allowed types are integer, float and string.',  | 
            ||
| 117 | 'parameters' => [],  | 
            ||
| 118 | ],  | 
            ||
| 119 | 'notNumberMessage' => [  | 
            ||
| 120 | 'template' => 'Value must be a number.',  | 
            ||
| 121 | 'parameters' => [],  | 
            ||
| 122 | ],  | 
            ||
| 123 | 'tooSmallMessage' => [  | 
            ||
| 124 |                                 'template' => 'Value must be no less than {min}.', | 
            ||
| 125 | 'parameters' => [  | 
            ||
| 126 | 'min' => null,  | 
            ||
| 127 | ],  | 
            ||
| 128 | ],  | 
            ||
| 129 | 'tooBigMessage' => [  | 
            ||
| 130 |                                 'template' => 'Value must be no greater than {max}.', | 
            ||
| 131 | 'parameters' => [  | 
            ||
| 132 | 'max' => 13,  | 
            ||
| 133 | ],  | 
            ||
| 134 | ],  | 
            ||
| 135 | 'skipOnEmpty' => false,  | 
            ||
| 136 | 'skipOnError' => false,  | 
            ||
| 137 | 'integerPattern' => '/1/',  | 
            ||
| 138 | 'numberPattern' => '/1/',  | 
            ||
| 139 | ],  | 
            ||
| 140 | [  | 
            ||
| 141 | 'test',  | 
            ||
| 142 | ],  | 
            ||
| 143 | ],  | 
            ||
| 144 | ],  | 
            ||
| 145 | ],  | 
            ||
| 146 | 'callable' => [  | 
            ||
| 147 | new Composite([  | 
            ||
| 148 |                     static fn () => (new Result())->addError('Bad value.'), | 
            ||
| 149 | ]),  | 
            ||
| 150 | [  | 
            ||
| 151 | 'skipOnEmpty' => false,  | 
            ||
| 152 | 'skipOnError' => false,  | 
            ||
| 153 | 'rules' => [  | 
            ||
| 154 | [  | 
            ||
| 155 | 'callback',  | 
            ||
| 156 | 'method' => null,  | 
            ||
| 157 | 'skipOnEmpty' => false,  | 
            ||
| 158 | 'skipOnError' => false,  | 
            ||
| 159 | ],  | 
            ||
| 160 | ],  | 
            ||
| 161 | ],  | 
            ||
| 162 | ],  | 
            ||
| 163 | 'inheritance' => [  | 
            ||
| 164 |                 new class () extends Composite { | 
            ||
| 165 | public function getRules(): iterable  | 
            ||
| 166 |                     { | 
            ||
| 167 | return [  | 
            ||
| 168 | new Required(),  | 
            ||
| 169 | ];  | 
            ||
| 170 | }  | 
            ||
| 171 | |||
| 172 | public function getOptions(): array  | 
            ||
| 173 |                     { | 
            ||
| 174 | return [  | 
            ||
| 175 | 'specific-key' => 42,  | 
            ||
| 176 | 'rules' => $this->dumpRulesAsArray(),  | 
            ||
| 177 | ];  | 
            ||
| 178 | }  | 
            ||
| 179 | },  | 
            ||
| 180 | [  | 
            ||
| 181 | 'specific-key' => 42,  | 
            ||
| 182 | 'rules' => [  | 
            ||
| 183 | [  | 
            ||
| 184 | 'required',  | 
            ||
| 185 | 'message' => [  | 
            ||
| 186 | 'template' => 'Value cannot be blank.',  | 
            ||
| 187 | 'parameters' => [],  | 
            ||
| 188 | ],  | 
            ||
| 189 | 'notPassedMessage' => [  | 
            ||
| 190 | 'template' => 'Value not passed.',  | 
            ||
| 191 | 'parameters' => [],  | 
            ||
| 192 | ],  | 
            ||
| 193 | 'skipOnError' => false,  | 
            ||
| 194 | ],  | 
            ||
| 350 |