Passed
Push — master ( 7a5018...5ee49d )
by Alessandro
01:01 queued 10s
created

CardsIdCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCardsId() 0 4 1
A createFromArray() 0 11 1
A createFromId() 0 4 1
1
<?php
2
3
4
namespace TrelloCycleTime\Collection;
5
6
7
use TrelloCycleTime\ValueObject\CardId;
8
9
class CardsIdCollection
10
{
11
    /**
12
     * @var array
13
     */
14
    private $cardsId;
15
16 5
    public function __construct(array $cardsId)
17
    {
18 5
        $this->cardsId = $cardsId;
19 5
    }
20
21
    /**
22
     * @return array
23
     */
24 5
    public function getCardsId(): array
25
    {
26 5
        return $this->cardsId;
27
    }
28
29 3
    public static function createFromArray(array $cards) :CardsIdCollection
30
    {
31 3
        $cardsId = array_map(
32
            function ($card) {
33 2
                return CardId::createFromId($card['id']);
34 3
            },
35
            $cards
36
        );
37
38 3
        return new self($cardsId);
39
    }
40
41 2
    public static function createFromId(string $cardId) :CardsIdCollection
42
    {
43 2
        return new self([CardId::createFromId($cardId)]);
44
    }
45
}