Passed
Pull Request — master (#15)
by Thijs
10:43
created

TransformsTeams::fromDevOpsTeam()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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