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

PlusForTrelloHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 20
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractEstimations() 0 16 3
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
}