1 | <?php |
||
17 | abstract class AbstractChecker |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Source database. |
||
22 | * |
||
23 | * @var ExtendedPdoInterface |
||
24 | */ |
||
25 | protected $sourceDatabase; |
||
26 | |||
27 | /** |
||
28 | * Target database. |
||
29 | * |
||
30 | * @var ExtendedPdoInterface |
||
31 | */ |
||
32 | protected $targetDatabase; |
||
33 | |||
34 | /** |
||
35 | * Cache. |
||
36 | * |
||
37 | * @var CacheProvider |
||
38 | */ |
||
39 | protected $cache; |
||
40 | |||
41 | /** |
||
42 | * Incidents. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private $_incidents = array(); |
||
47 | |||
48 | /** |
||
49 | * AbstractChecker constructor. |
||
50 | * |
||
51 | * @param CacheProvider $cache Cache provider. |
||
52 | */ |
||
53 | 10 | public function __construct(CacheProvider $cache) |
|
57 | |||
58 | /** |
||
59 | * Returns backwards compatibility checker name. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | abstract public function getName(); |
||
64 | |||
65 | /** |
||
66 | * Checks backwards compatibility and returns violations by category. |
||
67 | * |
||
68 | * @param ExtendedPdoInterface $source_db Source DB. |
||
69 | * @param ExtendedPdoInterface $target_db Target DB. |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | 6 | public function check(ExtendedPdoInterface $source_db, ExtendedPdoInterface $target_db) |
|
82 | |||
83 | /** |
||
84 | * Collects backwards compatibility violations. |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | abstract protected function doCheck(); |
||
89 | |||
90 | /** |
||
91 | * Builds string representation of a parameter. |
||
92 | * |
||
93 | * @param array $parameter_data Parameter data. |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 4 | protected function paramToString(array $parameter_data) |
|
134 | |||
135 | /** |
||
136 | * Determines if 2 param signatures are compatible. |
||
137 | * |
||
138 | * @param string $source_signature Source signature. |
||
139 | * @param string $target_signature Target signature. |
||
140 | * |
||
141 | * @return boolean |
||
142 | */ |
||
143 | 4 | protected function isParamSignatureCompatible($source_signature, $target_signature) |
|
182 | |||
183 | /** |
||
184 | * Decodes json-encoded PHP value. |
||
185 | * |
||
186 | * @param string $json_string JSON string. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | 3 | protected function decodeValue($json_string) |
|
198 | |||
199 | /** |
||
200 | * Adds incident. |
||
201 | * |
||
202 | * @param string $type Incident type. |
||
203 | * @param string $element Element affected. |
||
204 | * @param string|null $old_value Old value. |
||
205 | * @param string|null $new_value New value. |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | 4 | protected function addIncident($type, $element, $old_value = null, $new_value = null) |
|
223 | |||
224 | /** |
||
225 | * Returns cache key valid for specific database only. |
||
226 | * |
||
227 | * @param ExtendedPdoInterface $db Database. |
||
228 | * @param string $cache_key Cache key. |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | 2 | protected function getCacheKey(ExtendedPdoInterface $db, $cache_key) |
|
236 | |||
237 | } |
||
238 |