Completed
Push — master ( 634bb9...a5365b )
by Andrea
60:40 queued 56:03
created

ProjectPath::getRootPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\PannelloAmministrazioneBundle\Utils;
4
5
class ProjectPath
6
{
7
    /**
8
     * La funzione ritorna un array con i path dell'applicazione.
9
     *
10
     * @param $container Container dell'applicazione
11
     *
12
     * @return array Ritorna l'array contenente i path
13
     */
14
    private $rootdir;
15
    private $projectdir;
16
    private $cacheDir;
17
    private $logsDir;
18
19 3
    public function setRootDir($projectDir)
20
    {
21 3
        $this->projectdir = dirname($projectDir);
22 3
        $this->rootdir = dirname($projectDir);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
23 3
    }
24
25 3
    public function setCacheDir($cacheDir)
26
    {
27 3
        $this->cacheDir = $cacheDir;
28 3
    }
29
30 3
    public function setLogsDir($logsDir)
31
    {
32 3
        $this->logsDir = $logsDir;
33 3
    }
34
35 1
    public function getRootPath()
36
    {
37 1
        return $this->rootdir;
38
    }
39
40 3
    public function getProjectPath()
41
    {
42 3
        return $this->projectdir;
43
    }
44
45 1
    public function getBinPath()
46
    {
47 1
        $bindir = $this->getProjectPath().'/bin';
48 1
        if (!file_exists($bindir)) {
49 1
            $bindir = realpath($this->getProjectPath().'/../bin');
50
        }
51 1
        if (!file_exists($bindir)) {
52
            throw new \Exception('Cartella Bin non trovata', -100);
53
        }
54
55 1
        return $bindir;
56
    }
57
58 1
    public function getVendorBinPath()
59
    {
60 1
        $vendorbindir = $this->getProjectPath().DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'bin';
61 1
        if (!file_exists($vendorbindir)) {
62 1
            $vendorbindir = dirname($this->getProjectPath()).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'bin';
63 1
            if (!file_exists($vendorbindir)) {
64
                throw new \Exception('Cartella Bin in vendor non trovata', -100);
65
            }
66
        }
67
68 1
        return $vendorbindir;
69
    }
70
71 2
    public function getSrcPath()
72
    {
73 2
        $srcdir = $this->getProjectPath().DIRECTORY_SEPARATOR.'src';
74
75 2
        return $srcdir;
76
    }
77
78 1
    public function getPublicPath()
79
    {
80 1
        $publicdir = $this->getProjectPath().DIRECTORY_SEPARATOR.'public';
81
82 1
        return $publicdir;
83
    }
84
85 1
    public function getTemplatePath()
86
    {
87 1
        $srcdir = $this->getProjectPath().DIRECTORY_SEPARATOR.'templates';
88
89 1
        return realpath($srcdir);
90
    }
91
92 1
    public function getVarPath()
93
    {
94 1
        $vardir = $this->getProjectPath().DIRECTORY_SEPARATOR.'var';
95
96 1
        return realpath($vardir);
97
    }
98
99 1
    public function getDocPath()
100
    {
101 1
        $docdir = $this->getProjectPath().DIRECTORY_SEPARATOR.'doc';
102
103 1
        return realpath($docdir);
104
    }
105
106 1
    public function getCachePath()
107
    {
108 1
        $cachedir = $this->cacheDir;
109 1
        if (!file_exists($cachedir)) {
110
            throw new \Exception('Cache non trovata', -100);
111
        }
112
113 1
        return $cachedir;
114
    }
115
116 1
    public function getLogsPath()
117
    {
118 1
        $logsdir = $this->logsDir;
119 1
        if (!file_exists($logsdir)) {
120
            throw new \Exception('Logs non trovata', -100);
121
        }
122
123 1
        return $logsdir;
124
    }
125
126 1
    public function getConsole()
127
    {
128 1
        $console = $this->getBinPath().'/console';
129
        // Questo codice per versioni che usano un symfony 2 o 3
130 1
        if (!file_exists($console)) {
131
            throw new \Exception('Console non trovata', -100);
132
        }
133
134 1
        return $console;
135
    }
136
}
137