Completed
Pull Request — master (#3)
by Peter
01:50
created

Reference   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A createFromArray() 0 10 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Match;
4
5
use PtrTn\Battlerite\Assert\Assert;
6
7
class Reference
8
{
9
    /**
10
     * @var string
11
     */
12
    public $id;
13
14
    /**
15
     * @var string
16
     */
17
    public $type;
18
19 11
    private function __construct(
20
        string $type,
21
        string $id
22
    ) {
23 11
        $this->type = $type;
24 11
        $this->id = $id;
25 11
    }
26
27 11
    public static function createFromArray(array $reference): self
28
    {
29 11
        Assert::string($reference['type']);
30 11
        Assert::string($reference['id']);
31
32 11
        return new self(
33 11
            $reference['type'],
34 11
            $reference['id']
35
        );
36
    }
37
}
38