getDocumentationLinks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Facade\Ignition\Solutions;
4
5
use Facade\IgnitionContracts\Solution;
6
7
class SuggestCorrectVariableNameSolution implements Solution
8
{
9
    /** @var string */
10
    private $variableName;
11
12
    /** @var string */
13
    private $viewFile;
14
15
    public function __construct($variableName = null, $viewFile = null, $suggested = null)
16
    {
17
        $this->variableName = $variableName;
18
        $this->viewFile = $viewFile;
19
        $this->suggested = $suggested;
0 ignored issues
show
Bug introduced by
The property suggested does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
    }
21
22
    public function getSolutionTitle(): string
23
    {
24
        return 'Possible typo $'.$this->variableName;
25
    }
26
27
    public function getDocumentationLinks(): array
28
    {
29
        return [];
30
    }
31
32
    public function getSolutionDescription(): string
33
    {
34
        $path = str_replace(base_path().'/', '', $this->viewFile);
0 ignored issues
show
Unused Code introduced by
$path 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...
35
36
        return "Did you mean `$$this->suggested`?";
37
    }
38
39
    public function isRunnable(): bool
40
    {
41
        return false;
42
    }
43
}
44