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

Revision::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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