Test Failed
Push — main ( 92cbf8...131025 )
by Bingo
08:08
created

CandidateDeploymentImpl   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 36
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResources() 0 3 1
A getName() 0 3 1
A setResources() 0 3 1
A setName() 0 3 1
A fromDeploymentEntity() 0 5 1
1
<?php
2
3
namespace Jabe\Engine\Impl\Repository;
4
5
use Jabe\Engine\Impl\Persistence\Entity\{
6
    DeploymentEntity,
7
    ResourceEntity
8
};
9
use Jabe\Engine\Repository\{
10
    CandidateDeploymentInterface,
11
    ResourceInterface
12
};
13
14
class CandidateDeploymentImpl implements CandidateDeploymentInterface
15
{
16
    protected $name;
17
    protected $resources = [];
18
19
    public function __construct(string $name, array $resources)
20
    {
21
        $this->name = $name;
22
        $this->resources = $resources;
23
    }
24
25
    public function getName(): string
26
    {
27
        return $this->name;
28
    }
29
30
    public function setName(string $name): void
31
    {
32
        $this->name = $name;
33
    }
34
35
    public function getResources(): array
36
    {
37
        return $this->resources;
38
    }
39
40
    public function setResources(array $resources): void
41
    {
42
        $this->resources = $resources;
43
    }
44
45
    public static function fromDeploymentEntity(DeploymentEntity $deploymentEntity): CandidateDeploymentImpl
46
    {
47
        // first cast ResourceEntity map to Resource
48
        $resources = $deploymentEntity->getResources();
49
        return new CandidateDeploymentImpl($deploymentEntity->getName(), $resources);
50
    }
51
}
52