Passed
Push — develop ( 90329e...3ddada )
by Andrea
15:21
created

ProjectPath::getVendorPath()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ProjectPath::getPublicPath() 0 4 1
1
<?php
2
3
namespace Cdf\PannelloAmministrazioneBundle\DependencyInjection;
4
5
class ProjectPath
6
{
7
8
    /**
9
     * La funzione ritorna un array con i path dell'applicazione.
10
     *
11
     * @param $container Container dell'applicazione
12
     *
13
     * @return array Ritorna l'array contenente i path
14
     */
15
    private $container;
16
    private $rootdir;
17
    private $prjdir;
18
19 2
    public function __construct($container)
20
    {
21 2
        $this->container = $container;
22 2
        $rootdir = dirname($this->container->get('kernel')->getRootDir());
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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 2
        $this->rootdir = $rootdir;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
24 2
        $this->prjdir = $rootdir;
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...
25 2
    }
26 1
    public function getRootPath()
27
    {
28 1
        return $this->rootdir;
29
    }
30 2
    public function getProjectPath()
31
    {
32 2
        return $this->prjdir;
33
    }
34 1
    public function getBinPath()
35
    {
36 1
        $bindir = $this->getProjectPath() . '/bin';
37 1
        if (!file_exists($bindir)) {
38 1
            $bindir = realpath($this->getProjectPath() . '/../bin');
39
        }
40 1
        if (!file_exists($bindir)) {
41
            $bindir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'vendor' .
42
                    DIRECTORY_SEPARATOR . 'bin';
43
        }
44 1
        if (!file_exists($bindir)) {
45
            throw new \Exception("Cartella Bin non trovata", -100);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Cartella Bin non trovata does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
46
        }
47 1
        return $bindir;
48
    }
49 1
    public function getVendorBinPath()
50
    {
51 1
        $vendorbindir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin';
52 1
        if (!file_exists($vendorbindir)) {
53 1
            $vendorbindir = realpath($this->getProjectPath() . '/../vendor/bin');
54 1
            if (!file_exists($vendorbindir)) {
55
                throw new \Exception("Cartella Bin in vendor non trovata", -100);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Cartella Bin in vendor non trovata does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
56
            }
57
        }
58 1
        return $vendorbindir;
59
    }
60 2
    public function getSrcPath()
61
    {
62 2
        $srcdir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'src';
63 2
        return $srcdir;
64
    }
65
    public function getPublicPath()
66
    {
67
        $publicdir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'public';
68
        return $publicdir;
69
    }
70
    public function getAppPath()
71
    {
72
        $appdir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'app';
73
        return $appdir;
74
    }
75 1
    public function getTemplatePath()
76
    {
77 1
        $srcdir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'templates';
78 1
        return realpath($srcdir);
79
    }
80
    public function getVarPath()
81
    {
82
        $vardir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'var';
83
        return realpath($vardir);
84
    }
85 1
    public function getDocPath()
86
    {
87 1
        $docdir = $this->getProjectPath() . DIRECTORY_SEPARATOR . 'doc';
88 1
        return realpath($docdir);
89
    }
90 1
    public function getCachePath()
91
    {
92 1
        $cachedir = $this->container->get('kernel')->getCacheDir();
93 1
        if (!file_exists($cachedir)) {
94
            throw new \Exception("Cache non trovata", -100);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Cache non trovata does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
95
        }
96 1
        return $cachedir;
97
    }
98 1
    public function getLogsPath()
99
    {
100 1
        $logsdir = $this->container->get('kernel')->getLogDir();
101 1
        if (!file_exists($logsdir)) {
102
            throw new \Exception("Logs non trovata", -100);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Logs non trovata does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
103
        }
104 1
        return $logsdir;
105
    }
106 1
    public function getConsole()
107
    {
108 1
        $console = $this->getBinPath() . '/console';
109
        // Questo codice per versioni che usano un symfony 2 o 3
110 1
        if (!file_exists($console)) {
111
            throw new \Exception("Console non trovata", -100);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Console non trovata does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
112
        }
113 1
        return $console;
114
    }
115
}
116