Completed
Push — master ( 51faa5...529bf0 )
by Thijs
17s queued 14s
created

TransformsStates   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDevOpsStates() 0 7 1
A fromDevOpsState() 0 8 1
1
<?php
2
3
namespace TestMonitor\DevOps\Transforms;
4
5
use TestMonitor\DevOps\Validator;
6
use TestMonitor\DevOps\Resources\State;
7
8
trait TransformsStates
9
{
10
    /**
11
     * @param array $states
12
     *
13
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
14
     *
15
     * @return \TestMonitor\DevOps\Resources\State[]
16
     */
17 2
    protected function fromDevOpsStates($states): array
18
    {
19 2
        Validator::isArray($states);
20
21 2
        return array_map(function ($state) {
22 2
            return $this->fromDevOpsState($state);
23 2
        }, $states);
24
    }
25
26
    /**
27
     * @param array $state
28
     *
29
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
30
     *
31
     * @return \TestMonitor\DevOps\Resources\State
32
     */
33 2
    protected function fromDevOpsState($state): State
34
    {
35 2
        Validator::keysExists($state, ['name']);
36
37 2
        return new State([
38 2
            'name' => $state['name'],
39 2
            'color' => $state['color'],
40 2
            'category' => $state['category'] ?? '',
41 2
        ]);
42
    }
43
}
44