Round   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
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 58
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A createFromArray() 0 16 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Match;
4
5
use Webmozart\Assert\Assert;
6
7
class Round
8
{
9
    /**
10
     * @var string
11
     */
12
    public $type;
13
14
    /**
15
     * @var string
16
     */
17
    public $id;
18
19
    /**
20
     * @var int
21
     */
22
    public $duration;
23
24
    /**
25
     * @var int
26
     */
27
    public $ordinal;
28
29
    /**
30
     * @var int
31
     */
32
    public $winningTeam;
33
34 11
    private function __construct(
35
        string $type,
36
        string $id,
37
        int $duration,
38
        int $ordinal,
39
        int $winningTeam
40
    ) {
41 11
        $this->type = $type;
42 11
        $this->id = $id;
43 11
        $this->duration = $duration;
44 11
        $this->ordinal = $ordinal;
45 11
        $this->winningTeam = $winningTeam;
46 11
    }
47
48 11
    public static function createFromArray(array $round): self
49
    {
50 11
        Assert::string($round['type']);
51 11
        Assert::string($round['id']);
52 11
        Assert::integer($round['attributes']['duration']);
53 11
        Assert::integer($round['attributes']['ordinal']);
54 11
        Assert::integer($round['attributes']['stats']['winningTeam']);
55
56 11
        return new self(
57 11
            $round['type'],
58 11
            $round['id'],
59 11
            $round['attributes']['duration'],
60 11
            $round['attributes']['ordinal'],
61 11
            $round['attributes']['stats']['winningTeam']
62
        );
63
    }
64
}
65