Completed
Push — master ( 94c147...364ee1 )
by Thijs
15s queued 12s
created

TransformsProjects::fromDevOpsProjects()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace TestMonitor\DevOps\Transforms;
4
5
use TestMonitor\DevOps\Validator;
6
use TestMonitor\DevOps\Resources\Project;
7
8 View Code Duplication
trait TransformsProjects
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @param array $projects
12
     *
13
     * @return \TestMonitor\DevOps\Resources\Project[]
14 1
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
15
     */
16 1
    protected function fromDevOpsProjects($projects): array
17 1
    {
18 1
        Validator::isArray($projects);
19
20
        return array_map(function ($project) {
21
            return $this->fromDevOpsProject($project);
22
        }, $projects);
23
    }
24
25
    /**
26
     * @param array $project
27
     *
28
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
29
     * @return \TestMonitor\DevOps\Resources\Project
30
     */
31
    protected function fromDevOpsProject($project): Project
32
    {
33
        Validator::keysExists($project, ['id', 'name']);
34
35
        return new Project([
36
            'id' => $project['id'],
37
            'name' => $project['name'],
38
        ]);
39
    }
40
}
41