|
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 Track |
|
21
|
|
|
{ |
|
22
|
|
|
protected $model = false; |
|
23
|
|
|
protected $parent = false; |
|
24
|
|
|
|
|
25
|
|
|
protected $subTracks = []; |
|
26
|
|
|
protected $informate = []; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct($model, $parentTrack = false) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->setModel($model); |
|
31
|
|
|
$this->setParent($parentTrack); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function getParent() |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->parent; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function setParent($parent) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->parent = $parent; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getModel() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->model; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function setModel($model) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->model = $model; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
*/ |
|
58
|
|
|
public function addSubTrack(Track $track) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->subTracks[] = $track; |
|
61
|
|
|
} |
|
62
|
|
|
public function getSubTrack() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->subTracks; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* |
|
70
|
|
|
*/ |
|
71
|
|
|
public function addInformateArray($array) |
|
72
|
|
|
{ |
|
73
|
|
|
if (!is_array($array)) { |
|
74
|
|
|
return false; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
foreach ($array as $indice => $valor) { |
|
78
|
|
|
$this->addInformate($indice, $valor); |
|
79
|
|
|
} |
|
80
|
|
|
return true; |
|
81
|
|
|
} |
|
82
|
|
|
public function addInformate($name, $valor) |
|
83
|
|
|
{ |
|
84
|
|
|
$this->informate[$name] = $valor; |
|
85
|
|
|
} |
|
86
|
|
|
public function getInformate($name) |
|
87
|
|
|
{ |
|
88
|
|
|
if (!isset($this->informate[$name]) || empty($this->informate[$name])) { |
|
89
|
|
|
return false; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
return $this->informate[$name]; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Passa informacao pro pai |
|
97
|
|
|
*/ |
|
98
|
|
|
public function saveInformate($array) |
|
99
|
|
|
{ |
|
100
|
|
|
foreach ($array as $informate) { |
|
101
|
|
|
if ($informateInfo = $this->getInformate($informate[0])) { |
|
102
|
|
|
$informate[1]($informateInfo); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* |
|
111
|
|
|
*/ |
|
112
|
|
|
public function exec() |
|
113
|
|
|
{ |
|
114
|
|
|
// Carrega oq Precisa |
|
115
|
|
|
$this->loadSubTracks(); |
|
116
|
|
|
|
|
117
|
|
|
// Roda |
|
118
|
|
|
$this->run(); |
|
119
|
|
|
|
|
120
|
|
|
// ROdando os FIlhos |
|
121
|
|
|
if (is_array($trackingsChields = $this->getSubTrack())) { |
|
122
|
|
|
foreach ($trackingsChields as $trackingsChield) { |
|
123
|
|
|
$trackingsChield->exec()->saveInformate( |
|
124
|
|
|
$this->collectInformateFromSubTracks() |
|
|
|
|
|
|
125
|
|
|
); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* |
|
136
|
|
|
*/ |
|
137
|
|
|
public function loadSubTracks() |
|
138
|
|
|
{ |
|
139
|
|
|
foreach ($this->subTracks() as $relation => $classTrack) { |
|
140
|
|
|
$results = $this->model->$relation()->get(); |
|
|
|
|
|
|
141
|
|
|
foreach ($results as $result) { |
|
142
|
|
|
$this->addSubTrack(new $classTrack($result)); |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
|
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Reescrever |
|
151
|
|
|
*/ |
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
public function subTracks() |
|
155
|
|
|
{ |
|
156
|
|
|
return [ |
|
157
|
|
|
|
|
158
|
|
|
]; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
public function run() |
|
162
|
|
|
{ |
|
163
|
|
|
return true; |
|
164
|
|
|
} |
|
165
|
|
|
} |
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.