1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the SVN-Buddy library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/svn-buddy |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\SVNBuddy\Repository\RevisionLog; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
abstract class AbstractRevisionLogPlugin implements IRevisionLogPlugin |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Adds results for missing revisions. |
19
|
|
|
* |
20
|
|
|
* @param array $revisions Revisions. |
21
|
|
|
* @param array $results Results. |
22
|
|
|
* |
23
|
|
|
* @return array |
24
|
|
|
*/ |
25
|
|
|
protected function addMissingResults(array $revisions, array $results) |
26
|
|
|
{ |
27
|
|
|
foreach ( $this->_getMissingRevisions($revisions, $results) as $missing_revision ) { |
28
|
|
|
$results[$missing_revision] = array(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
return $results; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Adds results for missing revisions. |
36
|
|
|
* |
37
|
|
|
* @param array $revisions Revisions. |
38
|
|
|
* @param array $results Results. |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
* @throws \InvalidArgumentException When some revisions are missing in results. |
42
|
|
|
*/ |
43
|
|
|
protected function assertNoMissingRevisions(array $revisions, array $results) |
44
|
|
|
{ |
45
|
|
|
$missing_revisions = $this->_getMissingRevisions($revisions, $results); |
46
|
|
|
|
47
|
|
|
if ( !$missing_revisions ) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
throw new \InvalidArgumentException(sprintf( |
52
|
|
|
'Revision(-s) "%s" not found by "%s" plugin.', |
53
|
|
|
implode('", "', $missing_revisions), |
54
|
|
|
$this->getName() |
55
|
|
|
)); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns revisions, that are missing in results. |
60
|
|
|
* |
61
|
|
|
* @param array $revisions Revisions. |
62
|
|
|
* @param array $results Results. |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
private function _getMissingRevisions(array $revisions, array $results) |
67
|
|
|
{ |
68
|
|
|
return array_diff($revisions, array_keys($results)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|