Completed
Pull Request — master (#15)
by James
02:25
created

Revision   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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