Completed
Push — master ( 8c59ef...24dea2 )
by Alexander
03:02
created

GroupByRevisionMergeTemplate::generateGroupBody()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 2
crap 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
class GroupByRevisionMergeTemplate extends AbstractGroupByMergeTemplate
15
{
16
17
	/**
18
	 * Returns merge template name.
19
	 *
20
	 * @return string
21
	 */
22 2
	public function getName()
23
	{
24 2
		return 'group_by_revision';
25
	}
26
27
	/**
28
	 * Builds group body.
29
	 *
30
	 * @param array  $revisions  Revisions.
31
	 * @param string $source_url Source URL.
32
	 *
33
	 * @return string
34
	 */
35 1
	protected function generateGroupBody(array $revisions, $source_url)
36
	{
37 1
		$merged_messages = array();
38 1
		$revision_log = $this->revisionLogFactory->getRevisionLog($source_url);
39 1
		$revisions_data = $revision_log->getRevisionsData('summary', $revisions);
40
41 1
		foreach ( $revisions as $revision ) {
42 1
			$merged_messages[] = ' * r' . $revision . ': ' . $revisions_data[$revision]['msg'];
43
		}
44
45 1
		$merged_messages = array_unique(array_map('trim', $merged_messages));
46
47 1
		return implode(PHP_EOL, $merged_messages);
48
	}
49
50
}
51