TransformsTeams   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDevOpsTeams() 0 7 1
A fromDevOpsTeam() 0 9 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 1
    {
19
        Validator::isArray($teams);
20 1
21
        return array_map(function ($team) {
22 1
            return $this->fromDevOpsTeam($team);
23 1
        }, $teams);
24 1
    }
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 1
        Validator::keysExists($team, ['id', 'name']);
36
37 1
        return new Team([
38
            'id' => $team['id'],
39 1
            'name' => $team['name'],
40 1
            'description' => $team['description'],
41 1
            'path' => "{$team['projectName']}\\{$team['name']}",
42 1
        ]);
43 1
    }
44
}
45