Completed
Push — master ( 1e4e4c...8be129 )
by Marin
05:19
created

AbstractServer::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Anorgan\Deployer\Common\Server;
4
5
use Psr\Log\LoggerInterface;
6
use Psr\Log\NullLogger;
7
8
abstract class AbstractServer
9
{
10
    protected $title;
11
    protected $path;
12
13
    /**
14
     * @var LoggerInterface
15
     */
16
    protected $logger;
17
18
    protected $hostname = null;
19
20
    /**
21
     * @var array
22
     */
23
    protected $commands = [];
24
25
    /**
26
     * @param string          $title
27
     * @param string          $path
28
     * @param LoggerInterface $logger
29
     */
30 5
    public function __construct($title, $path, LoggerInterface $logger = null)
31
    {
32 5
        $this->title = $title;
33 5
        $this->path  = $path;
34
35 5
        if (null === $logger) {
36 2
            $logger = new NullLogger();
37
        }
38 5
        $this->logger = $logger;
39 5
    }
40
41
    /**
42
     * @param LoggerInterface $logger
43
     */
44
    public function setLogger($logger)
45
    {
46
        $this->logger = $logger;
47
    }
48
49
    /**
50
     * @return string
51
     */
52 1
    public function getTitle()
53
    {
54 1
        return $this->title;
55
    }
56
57
    /**
58
     * @param string $title
59
     */
60
    public function setTitle($title)
61
    {
62
        $this->title = $title;
63
    }
64
65
    /**
66
     * @return string
67
     */
68 1
    public function getPath()
69
    {
70 1
        return $this->path;
71
    }
72
73
    /**
74
     * @param string $path
75
     */
76
    public function setPath($path)
77
    {
78
        $this->path = $path;
79
    }
80
81
    /**
82
     * @return string
83
     */
84 1
    public function getHostname()
85
    {
86 1
        return $this->hostname;
87
    }
88
89
    /**
90
     * @param string $hostname
91
     */
92 2
    public function setHostname($hostname)
93
    {
94 2
        $this->hostname = $hostname;
95 2
    }
96
97
    /**
98
     * @return array
99
     */
100 2
    public function getCommands()
101
    {
102 2
        return $this->commands;
103
    }
104
105
    /**
106
     * @param array $commands
107
     */
108 2
    public function setCommands(array $commands)
109
    {
110 2
        $this->commands = $commands;
111 2
    }
112
113
    abstract public function runCommands();
114
}
115