Completed
Push — master ( 89612e...daf835 )
by Axel
02:08
created

PlusForTrelloHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 20
ccs 11
cts 12
cp 0.9167
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 2
    public static function extractEstimations(array $comments): array
10
    {
11 2
        $estimated = 0;
12 2
        $spent = 0;
13 2
        foreach ($comments as $comment) {
14 2
            $text = $comment['data']['text'];
15 2
            if (strpos($text, static::PREFIX) === false) {
16
                continue;
17
            }
18 2
            $parts = explode('/', $text);
19 2
            $spent += (float) array_reverse(explode(' ', $parts[0]))[0];
20 2
            $estimated += (float) $parts[1];
21
        }
22
        return [
23 2
            'estimated' => $estimated,
24 2
            'spent' => $spent
25
        ];
26
    }
27
}