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

TrelloBoard::getTransitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TrelloCycleTime;
6
7
use TrelloCycleTime\Client\TrelloApiClient;
8
use TrelloCycleTime\Collection\CardsIdCollection;
9
use TrelloCycleTime\Collection\HistoryCards;
10
use TrelloCycleTime\Collection\TimeCards;
11
12
final class TrelloBoard
13
{
14
15
    private $client;
16
17
    private $historyCardsCollection;
18
19
    private $timeCards;
20
    /**
21
     * @var string
22
     */
23
    private $boardId;
24
25 3
    public function __construct(TrelloApiClient $client, string $boardId)
26
    {
27 3
        $this->client = $client;
28 3
        $this->timeCards = new TimeCards();
29 3
        $this->boardId = $boardId;
30 3
    }
31
32 2
    public function getTransitions() :array
33
    {
34 2
        $cards = CardsIdCollection::createFromArray($this->client->findAllCards($this->boardId));
35
36 2
        $this->historyCardsCollection = HistoryCards::createFromCards($this->client, $cards->getCardsId());
37
38 2
        return $this->calculateTimeCardsCycleTime();
39
    }
40
41 1
    public function getCardTransitions(string $cardId) :array
42
    {
43 1
        $cards = CardsIdCollection::createFromId($cardId);
44
45 1
        $this->historyCardsCollection = HistoryCards::createFromCards($this->client, $cards->getCardsId());
46
47 1
        return $this->calculateTimeCardsCycleTime();
48
    }
49
50 3
    private function calculateTimeCardsCycleTime()
51
    {
52 3
        $timeCards = $this->timeCards->getFromHistoryCards($this->historyCardsCollection);
53
54 3
        $cycleTimeCalculator = new CycleTimeCalculator($timeCards, $this->historyCardsCollection);
55 3
        $cycleTimeCalculator->execute();
56
57
58 3
        return $cycleTimeCalculator->getTimeCards();
59
    }
60
}