ChangelogCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 15
c 2
b 0
f 0
dl 0
loc 34
ccs 0
cts 17
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 19 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\Command;
12
13
14
use Fiasco\SymfonyConsoleStyleMarkdown\Renderer;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
final class ChangelogCommand extends AbstractCommand
19
{
20
21
	/**
22
	 * {@inheritdoc}
23
	 */
24
	protected function configure()
25
	{
26
		$this
27
			->setName('changelog')
28
			->setDescription('Displays changes included in the current SVN-Buddy release');
29
30
		parent::configure();
31
	}
32
33
	protected function execute(InputInterface $input, OutputInterface $output)
34
	{
35
		$root_path = \dirname(__DIR__) . '/../..';
36
		$raw_changelog = \file_get_contents($root_path . '/CHANGELOG.md');
37
38
		$app_version = $this->getApplication()->getVersion();
39
40
		// Reassign all unreleased changes to current unstable version.
41
		if ( strpos($raw_changelog, $app_version) === false ) {
42
			$raw_changelog = str_replace(
43
				'[Unreleased]',
44
				'[' . $app_version . ']',
45
				$raw_changelog
46
			);
47
		}
48
49
		$markdown_renderer = Renderer::createFromMarkdown($raw_changelog);
50
51
		$this->io->writeln((string)$markdown_renderer);
52
	}
53
54
}
55