1 | <?php |
||
17 | abstract class AbstractPlugin implements IPlugin |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Database. |
||
22 | * |
||
23 | * @var ExtendedPdoInterface |
||
24 | */ |
||
25 | protected $database; |
||
26 | |||
27 | /** |
||
28 | * Repository filler. |
||
29 | * |
||
30 | * @var RepositoryFiller |
||
31 | */ |
||
32 | protected $repositoryFiller; |
||
33 | |||
34 | /** |
||
35 | * Parsing statistics. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $_statistics = array(); |
||
40 | |||
41 | /** |
||
42 | * Creates plugin instance. |
||
43 | * |
||
44 | * @param ExtendedPdoInterface $database Database. |
||
45 | * @param RepositoryFiller $repository_filler Repository filler. |
||
46 | */ |
||
47 | 105 | public function __construct(ExtendedPdoInterface $database, RepositoryFiller $repository_filler) |
|
54 | |||
55 | /** |
||
56 | * Resets parsing statistics. |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | 105 | private function _resetParsingStatistics() |
|
68 | |||
69 | /** |
||
70 | * Hook, that is called before "RevisionLog::refresh" method call. |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | 72 | public function whenDatabaseReady() |
|
78 | |||
79 | /** |
||
80 | * Records parsing statistics. |
||
81 | * |
||
82 | * @param string $type Type. |
||
83 | * @param integer $to_add Number to add. |
||
84 | * |
||
85 | * @return void |
||
86 | */ |
||
87 | 29 | protected function recordStatistic($type, $to_add = 1) |
|
91 | |||
92 | /** |
||
93 | * Returns parsing statistics. |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | 20 | public function getStatistics() |
|
101 | |||
102 | /** |
||
103 | * Adds results for missing revisions. |
||
104 | * |
||
105 | * @param array $revisions Revisions. |
||
106 | * @param array $results Results. |
||
107 | * |
||
108 | * @return array |
||
109 | */ |
||
110 | 4 | protected function addMissingResults(array $revisions, array $results) |
|
118 | |||
119 | /** |
||
120 | * Adds results for missing revisions. |
||
121 | * |
||
122 | * @param array $revisions Revisions. |
||
123 | * @param array $results Results. |
||
124 | * |
||
125 | * @return void |
||
126 | * @throws \InvalidArgumentException When some revisions are missing in results. |
||
127 | */ |
||
128 | 4 | protected function assertNoMissingRevisions(array $revisions, array $results) |
|
142 | |||
143 | /** |
||
144 | * Returns revisions, that are missing in results. |
||
145 | * |
||
146 | * @param array $revisions Revisions. |
||
147 | * @param array $results Results. |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | 8 | private function _getMissingRevisions(array $revisions, array $results) |
|
155 | |||
156 | /** |
||
157 | * Returns last revision processed by plugin. |
||
158 | * |
||
159 | * @return integer |
||
160 | */ |
||
161 | 48 | public function getLastRevision() |
|
170 | |||
171 | /** |
||
172 | * Sets last revision processed by plugin. |
||
173 | * |
||
174 | * @param integer $last_revision Last revision. |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | 35 | protected function setLastRevision($last_revision) |
|
184 | |||
185 | /** |
||
186 | * Finds project by path. |
||
187 | * |
||
188 | * @param string $path Path. |
||
189 | * |
||
190 | * @return integer |
||
191 | * @throws \InvalidArgumentException When project can't be found. |
||
192 | */ |
||
193 | 26 | protected function getProject($path) |
|
206 | |||
207 | /** |
||
208 | * Automatically free memory, when >200MB is used. |
||
209 | * |
||
210 | * @return void |
||
211 | * |
||
212 | * @codeCoverageIgnore |
||
213 | */ |
||
214 | protected function freeMemoryAutomatically() |
||
222 | |||
223 | /** |
||
224 | * Frees consumed memory manually. |
||
225 | * |
||
226 | * @return void |
||
227 | * |
||
228 | * @codeCoverageIgnore |
||
229 | */ |
||
230 | protected function freeMemoryManually() |
||
238 | |||
239 | } |
||
240 |