Passed
Push — master ( c21964...371444 )
by Alessandro
01:05 queued 18s
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\HistoryCards;
9
use TrelloCycleTime\Collection\TimeCards;
10
11
final class TrelloBoard
12
{
13
14
    private $client;
15
16
    private $historyCardsCollection;
17
18
    private $timeCards;
19
    /**
20
     * @var string
21
     */
22
    private $boardId;
23
24 2
    public function __construct(TrelloApiClient $client, string $boardId)
25
    {
26 2
        $this->client = $client;
27 2
        $this->timeCards = new TimeCards();
28 2
        $this->boardId = $boardId;
29 2
    }
30
31 2
    public function getTransitions() :array
32
    {
33 2
        $cards = $this->client->findAllCards($this->boardId);
34
35 2
        $this->historyCardsCollection = HistoryCards::createFromCards($this->client, $cards);
36
37 2
        return $this->calculateTimeCardsCycleTime();
38
    }
39
40 2
    private function calculateTimeCardsCycleTime()
41
    {
42 2
        $timeCards = $this->timeCards->getFromHistoryCards($this->historyCardsCollection);
43
44 2
        $cycleTimeCalculator = new CycleTimeCalculator($timeCards, $this->historyCardsCollection);
45 2
        $cycleTimeCalculator->execute();
46
47
48 2
        return $cycleTimeCalculator->getTimeCards();
49
    }
50
}