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

CardsIdCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
}