UuidValidation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isUuidValid() 0 8 2
A isValidUuidAgainstRegex() 0 8 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Imedia\Ammit\Domain;
5
6
/**
7
 * @author Guillaume MOREL <[email protected]>
8
 */
9
class UuidValidation
10
{
11
    /**
12
     * Valid against UUID format
13
     * @param string $string String to validate
14
     * @return bool
15
     */
16
    public function isUuidValid(string $string): bool
17
    {
18
        if ($this->isValidUuidAgainstRegex($string)) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return $this->isValidUuidAgainstRegex($string);.
Loading history...
19
            return true;
20
        }
21
22
        return false;
23
    }
24
25
    private function isValidUuidAgainstRegex($string): bool
26
    {
27
        if (preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $string)) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return (bool) preg_match...Fa-f]{12}$/', $string);.
Loading history...
28
            return true;
29
        }
30
31
        return false;
32
    }
33
}
34