Completed
Pull Request — master (#3)
by Peter
04:48
created

Reference::createFromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 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 6
    private function __construct(
20
        string $type,
21
        string $id
22
    ) {
23 6
        $this->type = $type;
24 6
        $this->id = $id;
25 6
    }
26
27 6
    public static function createFromArray(array $reference): self
28
    {
29 6
        Assert::string($reference['type']);
30 6
        Assert::string($reference['id']);
31
32 6
        return new self(
33 6
            $reference['type'],
34 6
            $reference['id']
35
        );
36
    }
37
}
38