Uuid   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 11 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Hop\Validator\Validator;
6
7
class Uuid implements RuleValidator
8
{
9
    use IsValidTrait;
10
11
    /**
12
     * @inheritdoc
13
     */
14 3
    public function getMessage($value, ?array $options)
15
    {
16 3
        if (!\is_scalar($value)) {
17 1
            return 'Param is not scalar';
18
        }
19
20 2
        if (!preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', (string)$value)) {
21 1
            return 'Pattern does not match UUID';
22
        }
23
24 1
        return null;
25
    }
26
}
27