ExtensionManagerTrait::getContents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Finder\Spider\Traits;
3
4
use Support\Helps\DebugHelper;
5
6
/**
7
 * Outputs events information to the console.
8
 *
9
 * @see TriggerableInterface
10
 */
11
trait ExtensionManagerTrait
12
{
13
    protected $file = false;
14
15
    protected function setFile($file)
16
    {
17
        if (is_string($file)) {
18
            $this->stringPath = true;
0 ignored issues
show
Bug introduced by
The property stringPath 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...
19
        }
20
        $this->file = $file;
21
    }
22
23
    public function getFile()
24
    {
25
        return $this->file;
26
    }
27
28
    public function getContents()
29
    {
30
        return $this->getFile()->getContents();
31
    }
32
33
    /**
34
     * Lógica
35
     */
36
    protected function run()
37
    {
38
        DebugHelper::debug('Run ExtensionManager '.$this->getFile());
39
        return $this->identificar();
40
    }
41
    protected function identificar()
42
    {
43
        if (!isset(static::$identificadores)) {
44
            return true;
45
        }
46
47
        if (empty(static::$identificadores)) {
48
            return true;
49
        }
50
51
        foreach (static::$identificadores as $identificador) {
52
            $identificadorInstance = new $identificador($this);
0 ignored issues
show
Unused Code introduced by
$identificadorInstance 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...
53
        }
54
        return true;
55
    }
56
}
57