Revision   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A fromSha1() 0 7 1
A __toString() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\Git;
6
7
use Assert\Assert;
8
use function rtrim;
9
10
final class Revision
11
{
12
    /** @var string */
13
    private $sha1;
14
15
    private function __construct()
16
    {
17
    }
18
19
    public static function fromSha1(string $sha1) : self
20
    {
21
        Assert::that($sha1)->regex('/^[a-zA-Z0-9]{40}$/');
22
        $instance       = new self();
23
        $instance->sha1 = rtrim($sha1);
24
25
        return $instance;
26
    }
27
28
    public function __toString() : string
29
    {
30
        return $this->sha1;
31
    }
32
}
33