Failed Conditions
Pull Request — master (#153)
by Alexander
02:32
created

ReparseCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 17
cp 0
rs 9.7998
cc 1
nc 1
nop 0
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\Command;
12
13
14
use ConsoleHelpers\ConsoleKit\Exception\CommandException;
15
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLog;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Input\InputOption;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
class ReparseCommand extends AbstractCommand
22
{
23
24
	/**
25
	 * Revision log
26
	 *
27
	 * @var RevisionLog
28
	 */
29
	private $_revisionLog;
30
31
	/**
32
	 * {@inheritdoc}
33
	 */
34
	protected function configure()
35
	{
36
		$this
37
			->setName('reparse')
38
			->setDescription('Reparses given revision')
39
			->addArgument(
40
				'path',
41
				InputArgument::OPTIONAL,
42
				'Working copy path',
43
				'.'
44
			)
45
			->addOption(
46
				'revision',
47
				'r',
48
				InputOption::VALUE_REQUIRED,
49
				'Reparse specified revision'
50
			);
51
52
		parent::configure();
53
	}
54
55
	/**
56
	 * {@inheritdoc}
57
	 */
58
	public function initialize(InputInterface $input, OutputInterface $output)
59
	{
60
		parent::initialize($input, $output);
61
62
		$this->_revisionLog = $this->getRevisionLog($this->getWorkingCopyUrl());
63
	}
64
65
	/**
66
	 * {@inheritdoc}
67
	 *
68
	 * @throws CommandException When mandatory "revision" option wasn't given.
69
	 */
70
	protected function execute(InputInterface $input, OutputInterface $output)
71
	{
72
		$revision = $this->io->getOption('revision');
73
74
		if ( !$revision ) {
75
			throw new CommandException('The "revision" option is mandatory.');
76
		}
77
78
		$this->_revisionLog->reparse($revision);
1 ignored issue
show
Bug introduced by
$revision of type string|string[]|true is incompatible with the type integer expected by parameter $revision of ConsoleHelpers\SVNBuddy\...\RevisionLog::reparse(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

78
		$this->_revisionLog->reparse(/** @scrutinizer ignore-type */ $revision);
Loading history...
79
	}
80
81
}
82