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(); |
|
|
|
|
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(); |
|
|
|
|
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()); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
protected static function clearUrl($url) |
82
|
|
|
{ |
83
|
|
|
return str_replace('./', '', $url); |
84
|
|
|
} |
85
|
|
|
} |
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.