Manager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Portiere\WebServer;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\Templating\EngineInterface;
7
8
/**
9
 * Class Manager.
10
 *
11
 * The Manager handles every web server possible action
12
 *
13
 * @author Ignacio Velazquez <[email protected]>
14
 */
15
abstract class Manager
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $config;
21
22
    /**
23
     * @var \Symfony\Component\Filesystem\Filesystem
24
     */
25
    protected $fs;
26
27
    /**
28
     * @var \Symfony\Component\Templating\PhpEngine
29
     */
30
    protected $templating;
31
32
    /**
33
     * Manager constructor.
34
     *
35
     * @param Filesystem      $fs
36
     * @param EngineInterface $templating
37
     */
38 2
    public function __construct(Filesystem $fs, EngineInterface $templating)
39
    {
40 2
        $this->fs = $fs;
41 2
        $this->templating = $templating;
0 ignored issues
show
Documentation Bug introduced by
$templating is of type object<Symfony\Component...lating\EngineInterface>, but the property $templating was declared to be of type object<Symfony\Component\Templating\PhpEngine>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
42 2
    }
43
44
    /**
45
     * Creates the virtual host related files.
46
     *
47
     * @param VhostInterface $vhost
48
     */
49
    abstract public function createVhost(VhostInterface $vhost);
50
51
    /**
52
     * Enables the virtual host.
53
     *
54
     * @param VhostInterface $vhost
55
     */
56
    abstract protected function enableVhost(VhostInterface $vhost);
57
58
    /**
59
     * Deletes all virtual host associated files.
60
     *
61
     * @param VhostInterface $vhost
62
     */
63
    abstract public function deleteVhost(VhostInterface $vhost);
64
65
    /**
66
     * Lists current virtual hosts.
67
     *
68
     * @return array [vhost name, enabled]
69
     */
70
    abstract public function listVhosts();
71
72
    /**
73
     * Gets the generated files for a virtual host.
74
     *
75
     * @param VhostInterface $vhost
76
     *
77
     * @return array
78
     */
79
    abstract public function getGeneratedFiles(VhostInterface $vhost);
80
81
    /**
82
     * Restarts web server.
83
     */
84
    abstract public function restartServer();
85
}
86