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