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

TransformsProjects   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 33
loc 33
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDevOpsProjects() 8 8 1
A fromDevOpsProject() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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