GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Md5::generateFromValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DBUnt1tled\VO\VObjects\Identity;
6
7
use DBUnt1tled\VO\Exception\InvalidVOArgumentException;
8
use DBUnt1tled\VO\VObjects\Scalar\Strings;
9
use DBUnt1tled\VO\VObjects\ValueObjectComplex;
10
use DBUnt1tled\VO\VObjects\ValueObjectInterface;
11
12
class Md5 extends ValueObjectComplex
13
{
14
15
    /**
16
     * @param mixed $value
17
     * @param mixed ...$other
18
     * @throws \ReflectionException
19
     */
20 2
    public function guard($value, ...$other): void
21
    {
22 2
        parent::guard($value);
23
        /** @var ValueObjectInterface $value*/
24 2
        if (false === (bool)preg_match('/^[a-f0-9]{32}$/', $value->getValue())) {
25 1
            throw new InvalidVOArgumentException('Value is not a valid md5 hash.', $value);
26
        }
27 1
    }
28
29
    /**
30
     * @param string $value
31
     * @return Md5
32
     * @throws \ReflectionException
33
     */
34 2
    public static function createFromString(string $value): self
35
    {
36 2
        return new static(new Strings($value));
37
    }
38
39
    /**
40
     * @param string $value
41
     * @return Md5
42
     * @throws \ReflectionException
43
     */
44 1
    public static function generateFromValue(string $value): self
45
    {
46 1
        return new static(new Strings(md5($value)));
47
    }
48
}
49