Completed
Push — master ( 30a2b5...89612e )
by Axel
02:59
created

PlusForTrelloHelper::extractEstimations()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 16
ccs 0
cts 16
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Scrumban\Utils;
4
5
class PlusForTrelloHelper
6
{
7
    const PREFIX = 'plus!';
8
    
9
    public static function extractEstimations(array $comments): array
10
    {
11
        $estimated = 0;
12
        $spent = 0;
13
        foreach ($comments as $comment) {
14
            $text = $comment['data']['text'];
15
            if (strpos($text, static::PREFIX) === false) {
16
                continue;
17
            }
18
            $parts = explode('/', $text);
19
            $estimated += (float) $parts[0];
20
            $spent += (float) $parts[1];
21
        }
22
        return [
23
            'estimated' => $estimated,
24
            'spent' => $spent
25
        ];
26
    }
27
}