| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 386 | 
| Code Lines | 295 | 
| 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 | ||
| 71 | public function dataOptions(): array | ||
| 72 |     { | ||
| 73 | return [ | ||
| 74 | [ | ||
| 75 | new Ip(), | ||
| 76 | [ | ||
| 77 | 'networks' => [ | ||
| 78 | '*' => ['any'], | ||
| 79 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 80 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 81 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 82 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 83 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 84 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 85 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 86 | ], | ||
| 87 | 'allowIpv4' => true, | ||
| 88 | 'allowIpv6' => true, | ||
| 89 | 'allowSubnet' => false, | ||
| 90 | 'requireSubnet' => false, | ||
| 91 | 'allowNegation' => false, | ||
| 92 | 'incorrectInputMessage' => [ | ||
| 93 | 'template' => 'The value must have a string type.', | ||
| 94 | 'parameters' => [], | ||
| 95 | ], | ||
| 96 | 'message' => [ | ||
| 97 | 'template' => 'Must be a valid IP address.', | ||
| 98 | 'parameters' => [], | ||
| 99 | ], | ||
| 100 | 'ipv4NotAllowedMessage' => [ | ||
| 101 | 'template' => 'Must not be an IPv4 address.', | ||
| 102 | 'parameters' => [], | ||
| 103 | ], | ||
| 104 | 'ipv6NotAllowedMessage' => [ | ||
| 105 | 'template' => 'Must not be an IPv6 address.', | ||
| 106 | 'parameters' => [], | ||
| 107 | ], | ||
| 108 | 'wrongCidrMessage' => [ | ||
| 109 | 'template' => 'Contains wrong subnet mask.', | ||
| 110 | 'parameters' => [], | ||
| 111 | ], | ||
| 112 | 'noSubnetMessage' => [ | ||
| 113 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 114 | 'parameters' => [], | ||
| 115 | ], | ||
| 116 | 'hasSubnetMessage' => [ | ||
| 117 | 'template' => 'Must not be a subnet.', | ||
| 118 | 'parameters' => [], | ||
| 119 | ], | ||
| 120 | 'notInRangeMessage' => [ | ||
| 121 | 'template' => 'Is not in the allowed range.', | ||
| 122 | 'parameters' => [], | ||
| 123 | ], | ||
| 124 | 'ranges' => [], | ||
| 125 | 'skipOnEmpty' => false, | ||
| 126 | 'skipOnError' => false, | ||
| 127 | ], | ||
| 128 | ], | ||
| 129 | [ | ||
| 130 | new Ip(allowIpv4: false), | ||
| 131 | [ | ||
| 132 | 'networks' => [ | ||
| 133 | '*' => ['any'], | ||
| 134 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 135 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 136 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 137 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 138 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 139 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 140 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 141 | ], | ||
| 142 | 'allowIpv4' => false, | ||
| 143 | 'allowIpv6' => true, | ||
| 144 | 'allowSubnet' => false, | ||
| 145 | 'requireSubnet' => false, | ||
| 146 | 'allowNegation' => false, | ||
| 147 | 'incorrectInputMessage' => [ | ||
| 148 | 'template' => 'The value must have a string type.', | ||
| 149 | 'parameters' => [], | ||
| 150 | ], | ||
| 151 | 'message' => [ | ||
| 152 | 'template' => 'Must be a valid IP address.', | ||
| 153 | 'parameters' => [], | ||
| 154 | ], | ||
| 155 | 'ipv4NotAllowedMessage' => [ | ||
| 156 | 'template' => 'Must not be an IPv4 address.', | ||
| 157 | 'parameters' => [], | ||
| 158 | ], | ||
| 159 | 'ipv6NotAllowedMessage' => [ | ||
| 160 | 'template' => 'Must not be an IPv6 address.', | ||
| 161 | 'parameters' => [], | ||
| 162 | ], | ||
| 163 | 'wrongCidrMessage' => [ | ||
| 164 | 'template' => 'Contains wrong subnet mask.', | ||
| 165 | 'parameters' => [], | ||
| 166 | ], | ||
| 167 | 'noSubnetMessage' => [ | ||
| 168 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 169 | 'parameters' => [], | ||
| 170 | ], | ||
| 171 | 'hasSubnetMessage' => [ | ||
| 172 | 'template' => 'Must not be a subnet.', | ||
| 173 | 'parameters' => [], | ||
| 174 | ], | ||
| 175 | 'notInRangeMessage' => [ | ||
| 176 | 'template' => 'Is not in the allowed range.', | ||
| 177 | 'parameters' => [], | ||
| 178 | ], | ||
| 179 | 'ranges' => [], | ||
| 180 | 'skipOnEmpty' => false, | ||
| 181 | 'skipOnError' => false, | ||
| 182 | ], | ||
| 183 | ], | ||
| 184 | [ | ||
| 185 | new Ip(allowIpv6: false), | ||
| 186 | [ | ||
| 187 | 'networks' => [ | ||
| 188 | '*' => ['any'], | ||
| 189 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 190 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 191 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 192 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 193 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 194 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 195 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 196 | ], | ||
| 197 | 'allowIpv4' => true, | ||
| 198 | 'allowIpv6' => false, | ||
| 199 | 'allowSubnet' => false, | ||
| 200 | 'requireSubnet' => false, | ||
| 201 | 'allowNegation' => false, | ||
| 202 | 'incorrectInputMessage' => [ | ||
| 203 | 'template' => 'The value must have a string type.', | ||
| 204 | 'parameters' => [], | ||
| 205 | ], | ||
| 206 | 'message' => [ | ||
| 207 | 'template' => 'Must be a valid IP address.', | ||
| 208 | 'parameters' => [], | ||
| 209 | ], | ||
| 210 | 'ipv4NotAllowedMessage' => [ | ||
| 211 | 'template' => 'Must not be an IPv4 address.', | ||
| 212 | 'parameters' => [], | ||
| 213 | ], | ||
| 214 | 'ipv6NotAllowedMessage' => [ | ||
| 215 | 'template' => 'Must not be an IPv6 address.', | ||
| 216 | 'parameters' => [], | ||
| 217 | ], | ||
| 218 | 'wrongCidrMessage' => [ | ||
| 219 | 'template' => 'Contains wrong subnet mask.', | ||
| 220 | 'parameters' => [], | ||
| 221 | ], | ||
| 222 | 'noSubnetMessage' => [ | ||
| 223 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 224 | 'parameters' => [], | ||
| 225 | ], | ||
| 226 | 'hasSubnetMessage' => [ | ||
| 227 | 'template' => 'Must not be a subnet.', | ||
| 228 | 'parameters' => [], | ||
| 229 | ], | ||
| 230 | 'notInRangeMessage' => [ | ||
| 231 | 'template' => 'Is not in the allowed range.', | ||
| 232 | 'parameters' => [], | ||
| 233 | ], | ||
| 234 | 'ranges' => [], | ||
| 235 | 'skipOnEmpty' => false, | ||
| 236 | 'skipOnError' => false, | ||
| 237 | ], | ||
| 238 | ], | ||
| 239 | [ | ||
| 240 | new Ip(allowSubnet: true), | ||
| 241 | [ | ||
| 242 | 'networks' => [ | ||
| 243 | '*' => ['any'], | ||
| 244 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 245 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 246 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 247 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 248 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 249 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 250 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 251 | ], | ||
| 252 | 'allowIpv4' => true, | ||
| 253 | 'allowIpv6' => true, | ||
| 254 | 'allowSubnet' => true, | ||
| 255 | 'requireSubnet' => false, | ||
| 256 | 'allowNegation' => false, | ||
| 257 | 'incorrectInputMessage' => [ | ||
| 258 | 'template' => 'The value must have a string type.', | ||
| 259 | 'parameters' => [], | ||
| 260 | ], | ||
| 261 | 'message' => [ | ||
| 262 | 'template' => 'Must be a valid IP address.', | ||
| 263 | 'parameters' => [], | ||
| 264 | ], | ||
| 265 | 'ipv4NotAllowedMessage' => [ | ||
| 266 | 'template' => 'Must not be an IPv4 address.', | ||
| 267 | 'parameters' => [], | ||
| 268 | ], | ||
| 269 | 'ipv6NotAllowedMessage' => [ | ||
| 270 | 'template' => 'Must not be an IPv6 address.', | ||
| 271 | 'parameters' => [], | ||
| 272 | ], | ||
| 273 | 'wrongCidrMessage' => [ | ||
| 274 | 'template' => 'Contains wrong subnet mask.', | ||
| 275 | 'parameters' => [], | ||
| 276 | ], | ||
| 277 | 'noSubnetMessage' => [ | ||
| 278 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 279 | 'parameters' => [], | ||
| 280 | ], | ||
| 281 | 'hasSubnetMessage' => [ | ||
| 282 | 'template' => 'Must not be a subnet.', | ||
| 283 | 'parameters' => [], | ||
| 284 | ], | ||
| 285 | 'notInRangeMessage' => [ | ||
| 286 | 'template' => 'Is not in the allowed range.', | ||
| 287 | 'parameters' => [], | ||
| 288 | ], | ||
| 289 | 'ranges' => [], | ||
| 290 | 'skipOnEmpty' => false, | ||
| 291 | 'skipOnError' => false, | ||
| 292 | ], | ||
| 293 | ], | ||
| 294 | [ | ||
| 295 | new Ip(requireSubnet: true), | ||
| 296 | [ | ||
| 297 | 'networks' => [ | ||
| 298 | '*' => ['any'], | ||
| 299 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 300 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 301 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 302 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 303 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 304 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 305 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 306 | ], | ||
| 307 | 'allowIpv4' => true, | ||
| 308 | 'allowIpv6' => true, | ||
| 309 | 'allowSubnet' => true, | ||
| 310 | 'requireSubnet' => true, | ||
| 311 | 'allowNegation' => false, | ||
| 312 | 'incorrectInputMessage' => [ | ||
| 313 | 'template' => 'The value must have a string type.', | ||
| 314 | 'parameters' => [], | ||
| 315 | ], | ||
| 316 | 'message' => [ | ||
| 317 | 'template' => 'Must be a valid IP address.', | ||
| 318 | 'parameters' => [], | ||
| 319 | ], | ||
| 320 | 'ipv4NotAllowedMessage' => [ | ||
| 321 | 'template' => 'Must not be an IPv4 address.', | ||
| 322 | 'parameters' => [], | ||
| 323 | ], | ||
| 324 | 'ipv6NotAllowedMessage' => [ | ||
| 325 | 'template' => 'Must not be an IPv6 address.', | ||
| 326 | 'parameters' => [], | ||
| 327 | ], | ||
| 328 | 'wrongCidrMessage' => [ | ||
| 329 | 'template' => 'Contains wrong subnet mask.', | ||
| 330 | 'parameters' => [], | ||
| 331 | ], | ||
| 332 | 'noSubnetMessage' => [ | ||
| 333 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 334 | 'parameters' => [], | ||
| 335 | ], | ||
| 336 | 'hasSubnetMessage' => [ | ||
| 337 | 'template' => 'Must not be a subnet.', | ||
| 338 | 'parameters' => [], | ||
| 339 | ], | ||
| 340 | 'notInRangeMessage' => [ | ||
| 341 | 'template' => 'Is not in the allowed range.', | ||
| 342 | 'parameters' => [], | ||
| 343 | ], | ||
| 344 | 'ranges' => [], | ||
| 345 | 'skipOnEmpty' => false, | ||
| 346 | 'skipOnError' => false, | ||
| 347 | ], | ||
| 348 | ], | ||
| 349 | [ | ||
| 350 | new Ip(allowNegation: true), | ||
| 351 | [ | ||
| 352 | 'networks' => [ | ||
| 353 | '*' => ['any'], | ||
| 354 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 355 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 356 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 357 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 358 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 359 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 360 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 361 | ], | ||
| 362 | 'allowIpv4' => true, | ||
| 363 | 'allowIpv6' => true, | ||
| 364 | 'allowSubnet' => false, | ||
| 365 | 'requireSubnet' => false, | ||
| 366 | 'allowNegation' => true, | ||
| 367 | 'incorrectInputMessage' => [ | ||
| 368 | 'template' => 'The value must have a string type.', | ||
| 369 | 'parameters' => [], | ||
| 370 | ], | ||
| 371 | 'message' => [ | ||
| 372 | 'template' => 'Must be a valid IP address.', | ||
| 373 | 'parameters' => [], | ||
| 374 | ], | ||
| 375 | 'ipv4NotAllowedMessage' => [ | ||
| 376 | 'template' => 'Must not be an IPv4 address.', | ||
| 377 | 'parameters' => [], | ||
| 378 | ], | ||
| 379 | 'ipv6NotAllowedMessage' => [ | ||
| 380 | 'template' => 'Must not be an IPv6 address.', | ||
| 381 | 'parameters' => [], | ||
| 382 | ], | ||
| 383 | 'wrongCidrMessage' => [ | ||
| 384 | 'template' => 'Contains wrong subnet mask.', | ||
| 385 | 'parameters' => [], | ||
| 386 | ], | ||
| 387 | 'noSubnetMessage' => [ | ||
| 388 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 389 | 'parameters' => [], | ||
| 390 | ], | ||
| 391 | 'hasSubnetMessage' => [ | ||
| 392 | 'template' => 'Must not be a subnet.', | ||
| 393 | 'parameters' => [], | ||
| 394 | ], | ||
| 395 | 'notInRangeMessage' => [ | ||
| 396 | 'template' => 'Is not in the allowed range.', | ||
| 397 | 'parameters' => [], | ||
| 398 | ], | ||
| 399 | 'ranges' => [], | ||
| 400 | 'skipOnEmpty' => false, | ||
| 401 | 'skipOnError' => false, | ||
| 402 | ], | ||
| 403 | ], | ||
| 404 | [ | ||
| 405 | new Ip(ranges: ['private']), | ||
| 406 | [ | ||
| 407 | 'networks' => [ | ||
| 408 | '*' => ['any'], | ||
| 409 | 'any' => ['0.0.0.0/0', '::/0'], | ||
| 410 | 'private' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 411 | 'multicast' => ['224.0.0.0/4', 'ff00::/8'], | ||
| 412 | 'linklocal' => ['169.254.0.0/16', 'fe80::/10'], | ||
| 413 | 'localhost' => ['127.0.0.0/8', '::1'], | ||
| 414 | 'documentation' => ['192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'], | ||
| 415 | 'system' => ['multicast', 'linklocal', 'localhost', 'documentation'], | ||
| 416 | ], | ||
| 417 | 'allowIpv4' => true, | ||
| 418 | 'allowIpv6' => true, | ||
| 419 | 'allowSubnet' => false, | ||
| 420 | 'requireSubnet' => false, | ||
| 421 | 'allowNegation' => false, | ||
| 422 | 'incorrectInputMessage' => [ | ||
| 423 | 'template' => 'The value must have a string type.', | ||
| 424 | 'parameters' => [], | ||
| 425 | ], | ||
| 426 | 'message' => [ | ||
| 427 | 'template' => 'Must be a valid IP address.', | ||
| 428 | 'parameters' => [], | ||
| 429 | ], | ||
| 430 | 'ipv4NotAllowedMessage' => [ | ||
| 431 | 'template' => 'Must not be an IPv4 address.', | ||
| 432 | 'parameters' => [], | ||
| 433 | ], | ||
| 434 | 'ipv6NotAllowedMessage' => [ | ||
| 435 | 'template' => 'Must not be an IPv6 address.', | ||
| 436 | 'parameters' => [], | ||
| 437 | ], | ||
| 438 | 'wrongCidrMessage' => [ | ||
| 439 | 'template' => 'Contains wrong subnet mask.', | ||
| 440 | 'parameters' => [], | ||
| 441 | ], | ||
| 442 | 'noSubnetMessage' => [ | ||
| 443 | 'template' => 'Must be an IP address with specified subnet.', | ||
| 444 | 'parameters' => [], | ||
| 445 | ], | ||
| 446 | 'hasSubnetMessage' => [ | ||
| 447 | 'template' => 'Must not be a subnet.', | ||
| 448 | 'parameters' => [], | ||
| 449 | ], | ||
| 450 | 'notInRangeMessage' => [ | ||
| 451 | 'template' => 'Is not in the allowed range.', | ||
| 452 | 'parameters' => [], | ||
| 453 | ], | ||
| 454 | 'ranges' => ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fd00::/8'], | ||
| 455 | 'skipOnEmpty' => false, | ||
| 456 | 'skipOnError' => false, | ||
| 457 | ], | ||
| 892 |