AbstractUuidCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isHexOnly() 0 5 1
A isCanonical() 0 5 1
1
<?php
2
3
namespace Mbright\Validation\Rule;
4
5
class AbstractUuidCase
6
{
7
    /**
8
     * Does the value match the canonical UUID format?
9
     *
10
     * @param string $value The value to be checked.
11
     *
12
     * @return bool
13
     */
14 63
    protected function isCanonical($value)
15
    {
16 63
        $regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
17
18 63
        return (bool) preg_match($regex, $value);
19
    }
20
21
    /**
22
     * Is the value a hex-only UUID?
23
     *
24
     * @param string $value The value to be checked.
25
     *
26
     * @return bool
27
     */
28 87
    protected function isHexOnly($value)
29
    {
30 87
        $regex = '/^[a-f0-9]{32}$/i';
31
32 87
        return (bool) preg_match($regex, $value);
33
    }
34
}
35