Passed
Pull Request — master (#15)
by Thijs
08:28 queued 03:03
created

TransformsTeams   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

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