Skip to content

Commit

Permalink
Refactored #83: Add command for disabling validators
Browse files Browse the repository at this point in the history
 - Removed using redundant $output param in the dependent files.
  • Loading branch information
andkirby committed Jul 29, 2016
1 parent 6d5dbc1 commit 9235203
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/lib/PreCommit/Command/Command/ClearCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->getCacheClearHelper()->clearIssueCache();
}
} catch (Exception $e) {
if ($this->isVeryVerbose($output)) {
if ($this->isVeryVerbose()) {
throw $e;
} else {
$output->writeln($e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion src/lib/PreCommit/Command/Command/Config/IgnoreCommit.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->disableProtection($input, $input->getOption('disable'));
$this->disableAllValidators($input, $input->getOption('disable'));

if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
if ($this->updated) {
$output->writeln(
'Validation will be ignored for the next commit.'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PreCommit/Command/Command/Config/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->writeKeyValueOption();

if ($this->updated) {
if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$this->output->writeln(
'Configuration updated.'
);
}
} else {
if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$this->output->writeln(
'Configuration already defined.'
);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PreCommit/Command/Command/Install/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getAvailableHooks()
protected function getTargetFiles(InputInterface $input, OutputInterface $output)
{
if (!$this->isAskedSpecificFile($input)) {
if ($this->isVeryVerbose($output)) {
if ($this->isVeryVerbose()) {
$output->writeln('All files mode.');
}

Expand Down Expand Up @@ -95,7 +95,7 @@ protected function getOptionTargetFiles(
InputInterface $input,
OutputInterface $output
) {
if ($this->isVeryVerbose($output)) {
if ($this->isVeryVerbose()) {
$output->writeln('Specific files mode.');
}
$files = array();
Expand Down
6 changes: 3 additions & 3 deletions src/lib/PreCommit/Command/Command/Install/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->getRunnerFile()
);
} catch (Exception $e) {
if ($this->isVeryVerbose($output)) {
if ($this->isVeryVerbose()) {
throw $e;
} else {
$output->writeln($e->getMessage());
Expand All @@ -50,7 +50,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}
}

if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$output->writeln(
"PHP CommitHook files have been created in '$hooksDir'."
);
Expand Down Expand Up @@ -196,7 +196,7 @@ protected function createHookFile(OutputInterface $output, InputInterface $input

$this->makeFileExecutable($file);

if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$output->writeln("CommitHook file set to '$file'.");
}

Expand Down
44 changes: 22 additions & 22 deletions src/lib/PreCommit/Command/Command/Install/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
*/
class Remove extends AbstractCommand
{
/**
* Init default helpers
*
* @return $this
*/
protected function configureCommand()
{
$this->setName('remove');
$this->setHelp(
'This command can remove installed hook files in your project.'
);
$this->setDescription(
'This command can remove installed hook files in your project.'
);

return $this;
}

/**
* Execute command
*
Expand All @@ -52,7 +34,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$files = $this->getTargetFiles($input, $output);
$status = $this->removeHookFiles($output, $hooksDir, $files);
} catch (Exception $e) {
if ($this->isVeryVerbose($output)) {
if ($this->isVeryVerbose()) {
throw $e;
} else {
$output->writeln($e->getMessage());
Expand All @@ -61,7 +43,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}
}
if ($status) {
if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$output->writeln("Existed CommitHook file(s) has been removed from '$hooksDir'.");
} else {
$output->writeln('Existed CommitHook file(s) has been removed.');
Expand All @@ -73,6 +55,24 @@ public function execute(InputInterface $input, OutputInterface $output)
return 0;
}

/**
* Init default helpers
*
* @return $this
*/
protected function configureCommand()
{
$this->setName('remove');
$this->setHelp(
'This command can remove installed hook files in your project.'
);
$this->setDescription(
'This command can remove installed hook files in your project.'
);

return $this;
}

/**
* Remove hook files
*
Expand All @@ -91,7 +91,7 @@ protected function removeHookFiles(
$file = $hooksDir.DIRECTORY_SEPARATOR.$filename;
if (!is_file($file)) {
//file not found
if ($this->isVerbose($output)) {
if ($this->isVerbose()) {
$output->writeln("Hook file '$filename' not found. Skipped.");
}
continue;
Expand All @@ -100,7 +100,7 @@ protected function removeHookFiles(
//cannot remove
$output->writeln("Hook file '$filename' cannot be removed. Skipped.");
continue;
} elseif ($this->isVerbose($output)) {
} elseif ($this->isVerbose()) {
//success removing
$output->writeln("Hook file '$filename' has removed.");
}
Expand Down

0 comments on commit 9235203

Please sign in to comment.