PublishSiteDirectory::default()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 74.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Acacha\ForgePublish\Commands;
4
5
/**
6
 * Class PublishSiteDirectory.
7
 *
8
 * @package Acacha\ForgePublish\Commands
9
 */
10 View Code Duplication
class PublishSiteDirectory extends SaveEnvVariable
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'publish:site_directory {site_directory?}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Save Acacha forge site directory';
25
26
    /**
27
     * Env var to set.
28
     *
29
     * @return mixed
30
     */
31
    protected function envVar()
32
    {
33
        return 'ACACHA_FORGE_SITE_DIRECTORY';
34
    }
35
36
    /**
37
     * Argument key.
38
     *
39
     * @return mixed
40
     */
41
    protected function argKey()
42
    {
43
        return 'site_directory';
44
    }
45
46
    /**
47
     * Question text.
48
     *
49
     * @return mixed
50
     */
51
    protected function questionText()
52
    {
53
        return 'Acacha forge site directory?';
54
    }
55
56
    /**
57
     * Default proposed value when asking.
58
     *
59
     */
60
    protected function default()
0 ignored issues
show
Coding Style introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
61
    {
62
        return $default = fp_env($this->envVar()) ? fp_env($this->envVar()) : $this->defaultValue();
0 ignored issues
show
Unused Code introduced by
$default is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
Coding Style introduced by
The visibility should be declared for property $default.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
63
    }
64
65
    /**
66
     * Default project type.
67
     *
68
     * @return string
69
     */
70
    protected function defaultValue()
71
    {
72
        return config('forge-publish.site_directory');
73
    }
74
}
75