Completed
Push — master ( ff821a...097dbe )
by Alexander
02:39
created

AbstractMergeTemplate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 64
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
getName() 0 1 ?
apply() 0 1 ?
A __construct() 0 7 1
A flattenMergedRevisions() 0 8 2
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\CommitMessage;
12
13
14
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector;
15
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory;
16
17
abstract class AbstractMergeTemplate
18
{
19
20
	/**
21
	 * Repository connector.
22
	 *
23
	 * @var Connector
24
	 */
25
	protected $repositoryConnector;
26
27
	/**
28
	 * Revision log factory.
29
	 *
30
	 * @var RevisionLogFactory
31
	 */
32
	protected $revisionLogFactory;
33
34
	/**
35
	 * Creates commit message builder instance.
36
	 *
37
	 * @param Connector          $repository_connector Repository connector.
38
	 * @param RevisionLogFactory $revision_log_factory Revision log factory.
39
	 */
40 13
	public function __construct(
41
		Connector $repository_connector,
42
		RevisionLogFactory $revision_log_factory
43
	) {
44 13
		$this->repositoryConnector = $repository_connector;
45 13
		$this->revisionLogFactory = $revision_log_factory;
46 13
	}
47
48
	/**
49
	 * Returns merge template name.
50
	 *
51
	 * @return string
52
	 */
53
	abstract public function getName();
54
55
	/**
56
	 * Applies merge template to a working copy.
57
	 *
58
	 * @param string $wc_path Working copy path.
59
	 *
60
	 * @return string
61
	 */
62
	abstract public function apply($wc_path);
63
64
	/**
65
	 * Flattens groups in revisions.
66
	 *
67
	 * @param array $grouped_revisions Grouped revisions.
68
	 *
69
	 * @return array
70
	 */
71 6
	protected function flattenMergedRevisions(array $grouped_revisions)
72
	{
73 6
		if ( count($grouped_revisions) > 1 ) {
74 3
			return \call_user_func_array('array_merge', $grouped_revisions);
75
		}
76
77 3
		return \array_values($grouped_revisions);
78
	}
79
80
}
81