1 | <?php |
||
18 | abstract class AbstractPlugin implements IPlugin |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Database. |
||
23 | * |
||
24 | * @var ExtendedPdoInterface |
||
25 | */ |
||
26 | protected $database; |
||
27 | |||
28 | /** |
||
29 | * Repository filler. |
||
30 | * |
||
31 | * @var RepositoryFiller |
||
32 | */ |
||
33 | protected $repositoryFiller; |
||
34 | |||
35 | /** |
||
36 | * Revision log. |
||
37 | * |
||
38 | * @var RevisionLog |
||
39 | */ |
||
40 | protected $revisionLog; |
||
41 | |||
42 | /** |
||
43 | * Parsing statistics. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | private $_statistics = array(); |
||
48 | |||
49 | /** |
||
50 | * Creates plugin instance. |
||
51 | * |
||
52 | * @param ExtendedPdoInterface $database Database. |
||
53 | * @param RepositoryFiller $repository_filler Repository filler. |
||
54 | */ |
||
55 | 117 | public function __construct(ExtendedPdoInterface $database, RepositoryFiller $repository_filler) |
|
62 | |||
63 | /** |
||
64 | * Resets parsing statistics. |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | 117 | private function _resetParsingStatistics() |
|
76 | |||
77 | /** |
||
78 | * Hook, that is called before "RevisionLog::refresh" method call. |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 72 | public function whenDatabaseReady() |
|
86 | |||
87 | /** |
||
88 | * Records parsing statistics. |
||
89 | * |
||
90 | * @param string $type Type. |
||
91 | * @param integer $to_add Number to add. |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | 30 | protected function recordStatistic($type, $to_add = 1) |
|
99 | |||
100 | /** |
||
101 | * Returns parsing statistics. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 21 | public function getStatistics() |
|
109 | |||
110 | /** |
||
111 | * Adds results for missing revisions. |
||
112 | * |
||
113 | * @param array $revisions Revisions. |
||
114 | * @param array $results Results. |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | 4 | protected function addMissingResults(array $revisions, array $results) |
|
126 | |||
127 | /** |
||
128 | * Adds results for missing revisions. |
||
129 | * |
||
130 | * @param array $revisions Revisions. |
||
131 | * @param array $results Results. |
||
132 | * |
||
133 | * @return void |
||
134 | * @throws \InvalidArgumentException When some revisions are missing in results. |
||
135 | */ |
||
136 | 4 | protected function assertNoMissingRevisions(array $revisions, array $results) |
|
150 | |||
151 | /** |
||
152 | * Returns revisions, that are missing in results. |
||
153 | * |
||
154 | * @param array $revisions Revisions. |
||
155 | * @param array $results Results. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | 8 | private function _getMissingRevisions(array $revisions, array $results) |
|
163 | |||
164 | /** |
||
165 | * Returns last revision processed by plugin. |
||
166 | * |
||
167 | * @return integer |
||
168 | */ |
||
169 | 49 | public function getLastRevision() |
|
178 | |||
179 | /** |
||
180 | * Sets last revision processed by plugin. |
||
181 | * |
||
182 | * @param integer $last_revision Last revision. |
||
183 | * |
||
184 | * @return void |
||
185 | */ |
||
186 | 38 | protected function setLastRevision($last_revision) |
|
192 | |||
193 | /** |
||
194 | * Finds project by path. |
||
195 | * |
||
196 | * @param string $path Path. |
||
197 | * |
||
198 | * @return integer |
||
199 | * @throws \InvalidArgumentException When project can't be found. |
||
200 | */ |
||
201 | 35 | protected function getProject($path) |
|
214 | |||
215 | /** |
||
216 | * Automatically free memory, when >200MB is used. |
||
217 | * |
||
218 | * @return void |
||
219 | * |
||
220 | * @codeCoverageIgnore |
||
221 | */ |
||
222 | protected function freeMemoryAutomatically() |
||
230 | |||
231 | /** |
||
232 | * Frees consumed memory manually. |
||
233 | * |
||
234 | * @return void |
||
235 | * |
||
236 | * @codeCoverageIgnore |
||
237 | */ |
||
238 | protected function freeMemoryManually() |
||
246 | |||
247 | /** |
||
248 | * Sets reference to revision log. |
||
249 | * |
||
250 | * @param RevisionLog $revision_log Revision log. |
||
251 | * |
||
252 | * @return void |
||
253 | */ |
||
254 | 2 | public function setRevisionLog(RevisionLog $revision_log) |
|
258 | |||
259 | } |
||
260 |