Passed
Push — master ( 5ee49d...ede548 )
by Alessandro
01:05 queued 11s
created

CycleTimesCollection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFromCardHistory() 0 15 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TrelloCycleTime\Collection;
6
7
8
use TrelloCycleTime\ValueObject\CycleTime;
9
10
class CycleTimesCollection
11
{
12
    private $cycleTimeCollection;
13
14 5
    public function __construct()
15
    {
16 5
        $this->cycleTimeCollection = [];
17 5
    }
18
19 5
    public function getFromCardHistory(array $cardHistories): array
20
    {
21 5
        foreach ($cardHistories as $history) {
22 4
            if ($history->getFrom() === null || $history->getFrom() === '') {
23 2
                continue;
24
            }
25
            
26 4
            $cycleTimeColumn = CycleTime::createFromCardHistory($history);
27 4
            if (!isset($this->cycleTimeCollection[$cycleTimeColumn->getName()])) {
0 ignored issues
show
Bug introduced by
Consider using $cycleTimeColumn->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
28 4
                $this->cycleTimeCollection[$cycleTimeColumn->getName()] = $cycleTimeColumn;
0 ignored issues
show
Bug introduced by
Consider using $cycleTimeColumn->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
29
            }
30
        }
31
32 5
        return $this->cycleTimeCollection;
33
    }
34
}