IpAddress::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\Doorkeeper\Identification;
6
7
final class IpAddress extends AbstractIdentification
8
{
9
    protected function validate($ipAddress): void
10
    {
11
        if (
12
            !filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)
13
            && !filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)
14
        ) {
15
            throw new \InvalidArgumentException("{$ipAddress} is not a well formed ip address");
16
        }
17
    }
18
}
19