Source   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildFromArray() 0 6 2
A __construct() 0 5 1
1
<?php
2
3
namespace CompoLab\Domain;
4
5
use CompoLab\Domain\Type\Factory;
6
use CompoLab\Domain\Type\Git;
7
use CompoLab\Domain\Type\Type;
8
use CompoLab\Domain\Utils\JsonConvertible;
9
use CompoLab\Domain\Utils\JsonConvertibleTrait;
10
use CompoLab\Domain\ValueObject\Reference;
11
use CompoLab\Domain\ValueObject\Url;
12
13
final class Source implements JsonConvertible
14
{
15
    use JsonConvertibleTrait;
16
17
    /** @var Type */
18
    private $type;
19
20
    /** @var Url */
21
    private $url;
22
23
    /** @var Reference */
24
    private $reference;
25
26 7
    public function __construct(Type $type, Url $url, Reference $reference)
27
    {
28 7
        $this->type = $type;
29 7
        $this->url = $url;
30 7
        $this->reference = $reference;
31 7
    }
32
33 6
    public static function buildFromArray(array $data): self
34
    {
35 6
        return new self(
36 6
            isset($data['type']) ? Factory::buildFromString($data['type']) : new Git,
37 6
            new Url($data['url']),
38 6
            new Reference($data['reference'])
39
        );
40
    }
41
}
42