Completed
Push — master ( 89ed1a...e7e380 )
by Tom
07:14
created

Directories   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 57
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPipelineLocalDeploy() 0 3 1
A getName() 0 3 1
A getProject() 0 3 1
A __construct() 0 13 3
1
<?php
2
3
/*
4
 * pipelines
5
 *
6
 * Date: 10.06.18 22:13
7
 */
8
9
namespace Ktomk\Pipelines\Runner;
10
11
use InvalidArgumentException;
12
13
class Directories
14
{
15
    /**
16
     * @var string
17
     */
18
    private $project;
19
20
    /**
21
     * @var array
22
     */
23
    private $server;
24
25
    /**
26
     * Directories constructor.
27
     *
28
     * @param array $server
29
     * @param string $project directory
30
     */
31 6
    public function __construct(array $server, $project)
32
    {
33 6
        if (!basename($project)) {
34 1
            throw new InvalidArgumentException(sprintf('Invalid project directory "%s"', $project));
35
        }
36
37 5
        $this->project = $project;
38
39 5
        if (!isset($server['HOME'])) {
40 1
            throw new InvalidArgumentException('Server must contain a "HOME" entry');
41
        }
42
43 4
        $this->server = $server;
44 4
    }
45
46
    /**
47
     * basename of the project directory
48
     *
49
     * @return string
50
     */
51 2
    public function getName()
52
    {
53 2
        return basename($this->project);
54
    }
55
56
    /**
57
     * @return string
58
     */
59 1
    public function getProject()
60
    {
61 1
        return $this->project;
62
    }
63
64
    /**
65
     * @return string
66
     */
67 1
    public function getPipelineLocalDeploy()
68
    {
69 1
        return sprintf('%s/.pipelines/%s', $this->server['HOME'], $this->getName());
70
    }
71
}
72