| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 115 | 
| Code Lines | 70 | 
| 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  | 
            ||
| 114 | public function dataValidationFailed(): array  | 
            ||
| 115 |     { | 
            ||
| 116 | $errors = ['' => ['This value is not a subset of acceptable values.']];  | 
            ||
| 117 | |||
| 118 | return [  | 
            ||
| 119 | 'non-iterable' => [  | 
            ||
| 120 | 1,  | 
            ||
| 121 | [new Subset([1, 2, 3])],  | 
            ||
| 122 | ['' => ['Value must be iterable.']],  | 
            ||
| 123 | ],  | 
            ||
| 124 | 'custom incorrect input message' => [  | 
            ||
| 125 | 1,  | 
            ||
| 126 | [new Subset([1, 2, 3], incorrectInputMessage: 'Custom non-iterable message.')],  | 
            ||
| 127 | ['' => ['Custom non-iterable message.']],  | 
            ||
| 128 | ],  | 
            ||
| 129 | 'custom incorrect input message with parameters' => [  | 
            ||
| 130 | 1,  | 
            ||
| 131 |                 [new Subset([1, 2, 3], incorrectInputMessage: 'Attribute - {attribute}, type - {type}.')], | 
            ||
| 132 | ['' => ['Attribute - , type - int.']],  | 
            ||
| 133 | ],  | 
            ||
| 134 | 'custom incorrect input message with parameters, attribute set' => [  | 
            ||
| 135 | ['data' => 1],  | 
            ||
| 136 |                 ['data' => new Subset([1, 2, 3], incorrectInputMessage: 'Attribute - {attribute}, type - {type}.')], | 
            ||
| 137 | ['data' => ['Attribute - data, type - int.']],  | 
            ||
| 138 | ],  | 
            ||
| 139 | [  | 
            ||
| 140 | [0, 1, 2],  | 
            ||
| 141 | [new Subset(range(1, 10))],  | 
            ||
| 142 | $errors,  | 
            ||
| 143 | ],  | 
            ||
| 144 | [  | 
            ||
| 145 | [10, 11, 12],  | 
            ||
| 146 | [new Subset(range(1, 10))],  | 
            ||
| 147 | $errors,  | 
            ||
| 148 | ],  | 
            ||
| 149 | 'iterator as a value' => [  | 
            ||
| 150 | new SingleValueDataSet(new ArrayObject(['c', 'd'])),  | 
            ||
| 151 | [new Subset(new ArrayObject(['a', 'b', 'c']))],  | 
            ||
| 152 | $errors,  | 
            ||
| 153 | ],  | 
            ||
| 154 | |||
| 155 | 'arrays, non-strict equality (partially), strict mode' => [  | 
            ||
| 156 | [['1', 2], ['3', 4]],  | 
            ||
| 157 | [new Subset([[1, 2], [3, 4], [5, 6]], strict: true)],  | 
            ||
| 158 | $errors,  | 
            ||
| 159 | ],  | 
            ||
| 160 | 'arrays, non-strict equality (fully), strict mode' => [  | 
            ||
| 161 | [['1', '2'], ['3', '4']],  | 
            ||
| 162 | [new Subset([[1, 2], [3, 4], [5, 6]], strict: true)],  | 
            ||
| 163 | $errors,  | 
            ||
| 164 | ],  | 
            ||
| 165 | 'arrays, items are not from acceptable list' => [  | 
            ||
| 166 | [[7, 8], [9, 10]],  | 
            ||
| 167 | [new Subset([[1, 2], [3, 4], [5, 6]], strict: true)],  | 
            ||
| 168 | $errors,  | 
            ||
| 169 | ],  | 
            ||
| 170 | 'arrays, items from acceptable list but not as units' => [  | 
            ||
| 171 | [[2, 3], [4, 5]],  | 
            ||
| 172 | [new Subset([[1, 2], [3, 4], [5, 6]], strict: true)],  | 
            ||
| 173 | $errors,  | 
            ||
| 174 | ],  | 
            ||
| 175 | 'arrays, nested, not all items are from acceptable list' => [  | 
            ||
| 176 | [  | 
            ||
| 177 | ['data' => ['value' => [3, 4]]],  | 
            ||
| 178 | ['data' => ['value' => [5, 7]]],  | 
            ||
| 179 | ],  | 
            ||
| 180 | [  | 
            ||
| 181 | new Subset([  | 
            ||
| 182 | ['data' => ['value' => [1, 2]]],  | 
            ||
| 183 | ['data' => ['value' => [3, 4]]],  | 
            ||
| 184 | ['data' => ['value' => [5, 6]]],  | 
            ||
| 185 | ]),  | 
            ||
| 186 | ],  | 
            ||
| 187 | $errors,  | 
            ||
| 188 | ],  | 
            ||
| 189 | 'arrays, nested, reversed order of values in lists' => [  | 
            ||
| 190 | [  | 
            ||
| 191 | [  | 
            ||
| 192 | 'data2' => ['value2' => [8, 7], 'value1' => [6, 5]],  | 
            ||
| 193 | 'data1' => ['value2' => [4, 3], 'value1' => [2, 1]],  | 
            ||
| 194 | ],  | 
            ||
| 195 | [  | 
            ||
| 196 | 'data2' => ['value2' => [16, 15], 'value1' => [14, 13]],  | 
            ||
| 197 | 'data1' => ['value2' => [12, 11], 'value1' => [10, 9]],  | 
            ||
| 198 | ],  | 
            ||
| 199 | ],  | 
            ||
| 200 | [  | 
            ||
| 201 | new Subset([  | 
            ||
| 202 | [  | 
            ||
| 203 | 'data1' => ['value1' => [1, 2], 'value2' => [3, 4]],  | 
            ||
| 204 | 'data2' => ['value1' => [5, 6], 'value2' => [7, 8]],  | 
            ||
| 205 | ],  | 
            ||
| 206 | [  | 
            ||
| 207 | 'data1' => ['value1' => [9, 10], 'value2' => [11, 12]],  | 
            ||
| 208 | 'data2' => ['value1' => [13, 14], 'value2' => [15, 16]],  | 
            ||
| 209 | ],  | 
            ||
| 210 | ]),  | 
            ||
| 211 | ],  | 
            ||
| 212 | $errors,  | 
            ||
| 213 | ],  | 
            ||
| 214 | |||
| 215 | 'custom message' => [  | 
            ||
| 216 | ['' => ['c']],  | 
            ||
| 217 | ['' => new Subset(['a', 'b'], message: 'Custom message.')],  | 
            ||
| 218 | ['' => ['Custom message.']],  | 
            ||
| 219 | ],  | 
            ||
| 220 | 'custom message with parameters' => [  | 
            ||
| 221 | ['' => ['c']],  | 
            ||
| 222 |                 ['' => new Subset(['a', 'b'], message: 'Attribute - {attribute}.')], | 
            ||
| 223 | ['' => ['Attribute - .']],  | 
            ||
| 224 | ],  | 
            ||
| 225 | 'custom message with parameters, attribute set' => [  | 
            ||
| 226 | ['data' => ['c']],  | 
            ||
| 227 |                 ['data' => new Subset(['a', 'b'], message: 'Attribute - {attribute}.')], | 
            ||
| 228 | ['data' => ['Attribute - data.']],  | 
            ||
| 229 | ],  | 
            ||
| 249 |