UserId::validate()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 15
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\Doorkeeper\Identification;
6
7
use Ramsey\Uuid;
8
9
final class UserId extends AbstractIdentification
10
{
11
    protected function validate($value): void
12
    {
13
        if (is_int($value)) {
14
            return;
15
        }
16
17
        if (Uuid\Uuid::isValid((string) $value)) {
18
            return;
19
        }
20
21
        if (is_string($value)) {
22
            return;
23
        }
24
25
        throw new \InvalidArgumentException("{$value} is not an integer or uuid");
26
    }
27
}
28