IdentificadorManagerTrait::collectData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Finder\Spider\Traits;
3
4
use Support\Helps\DebugHelper;
5
use Finder\Contracts\Spider\ExtensionManager;
6
7
/**
8
 * Outputs events information to the console.
9
 *
10
 * @see TriggerableInterface
11
 */
12
trait IdentificadorManagerTrait
13
{
14
    protected $extension = false;
15
16
    protected function setExtension(ExtensionManager $extension)
17
    {
18
        $this->extension = $extension;
0 ignored issues
show
Documentation Bug introduced by
It seems like $extension of type object<Finder\Contracts\Spider\ExtensionManager> is incompatible with the declared type boolean of property $extension.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
19
    }
20
21
    public function getExtension()
22
    {
23
        return $this->extension;
24
    }
25
26
    public function getFile()
27
    {
28
        return $this->getExtension()->getFile();
29
    }
30
31
    public function getContents()
32
    {
33
        return $this->getExtension()->getContents();
34
    }
35
36
    /**
37
     * Lógica
38
     */
39
    protected function run()
40
    {
41
        DebugHelper::debug('Run Identificador '.$this->getFile());
42
        if ($this->identify()) {
0 ignored issues
show
Bug introduced by
It seems like identify() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
43
            DebugHelper::info('Arquivo identificado'.$this->getFile());
44
            $this->collectData();
45
        }
46
    }
47
48
    protected function doCollect()
49
    {
50
        $this->collectData();
51
    }
52
53
    public function collectData()
54
    {
55
        // @todo Fazer Aqui
56
        $this->collectDataEstrutura();
0 ignored issues
show
Bug introduced by
The method collectDataEstrutura() does not exist on Finder\Spider\Traits\IdentificadorManagerTrait. Did you maybe mean collectData()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
57
    }
58
}
59