TargetManager::getUniqueIdentify()   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\Contracts\Spider;
3
4
use Finder\Logic\Output\AbstractOutput;
5
use Finder\Logic\Output\Filter\OutputFilterInterface;
6
use Finder\Logic\Output\TriggerableInterface;
7
8
use Symfony\Component\Finder\Finder;
9
10
use Finder\Spider\File;
11
use Finder\Spider\Directory;
12
use Finder\Spider\Registrator\FileRegistrator;
13
use Finder\Spider\Metrics\FileMetric;
14
15
use Support\Helps\DebugHelper;
16
17
/**
18
 * Run all script analysers and outputs their result.
19
 */
20
abstract class TargetManager
21
{
22
    protected $target = false;
23
    protected $parent = false;
24
    protected $isStringPath = false;
25
26
    public function __construct($target, $parent = false)
27
    {
28
        $this->setTarget($target);
29
        $this->setParent($parent);
30
    }
31
32
    public function getUniqueIdentify()
33
    {
34
        // @todo reescrever
35
        return $target->getTargetPath();
0 ignored issues
show
Bug introduced by
The variable $target does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
36
    }
37
38
    public function getParent()
39
    {
40
        return $this->parent;
41
    }
42
43
    public function setParent($parent)
44
    {
45
        $this->parent = $parent;
46
    }
47
48
    public function getTarget()
49
    {
50
        return $this->target;
51
    }
52
53
    protected function setTarget($target)
54
    {
55
        if (is_string($target)) {
56
            $this->isStringPath = true;
57
        }
58
        $this->target = $target;
59
    }
60
61
    public function getTargetPath()
62
    {
63
        if (is_string($this->getTarget())) {
64
            return $this->getTarget();
65
        }
66
67
        return $this->getTarget()->getRealPath();
0 ignored issues
show
Bug introduced by
The method getRealPath cannot be called on $this->getTarget() (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
68
    }
69
70
    public function getLocation()
71
    {
72
73
        if ($this->isStringPath) {
74
            return $this->getTarget();
75
        }
76
77
78
        return self::clearUrl($this->getTarget()->getRealPath());
0 ignored issues
show
Bug introduced by
The method getRealPath cannot be called on $this->getTarget() (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
79
    }
80
81
    protected static function clearUrl($url)
82
    {
83
        return str_replace('./', '', $url);
84
    }
85
}