Skip to content

Commit 8ae4c6f

Browse files
committed
Merge pull request #10 from php-cache/patch3
refactored the command
2 parents f9bdb96 + 8d1cd69 commit 8ae4c6f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/Command/CacheFlushCommand.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,24 @@ protected function configure()
4040
*/
4141
protected function execute(InputInterface $input, OutputInterface $output)
4242
{
43-
$validTypes = ['session', 'routing', 'doctrine', 'all'];
43+
$validTypes = ['session', 'routing', 'doctrine'];
4444
$type = $input->getArgument('type');
45-
if (!in_array($type, $validTypes)) {
46-
$output->writeln(sprintf('Type "%s" does not exist. Valid type are: %s', $type, implode(',', $validTypes)));
47-
}
48-
4945
if ($type === 'all') {
50-
foreach (['session', 'routing', 'doctrine'] as $type) {
46+
foreach ($validTypes as $type) {
5147
$this->clearCacheForType($type);
5248
}
53-
} else {
54-
$this->clearCacheForType($type);
49+
50+
return;
5551
}
52+
53+
// If not "all", verify that $type is valid
54+
if (!in_array($type, $validTypes)) {
55+
$output->writeln(sprintf('Type "%s" does not exist. Valid type are: %s', $type, implode(',', $validTypes)));
56+
57+
return;
58+
}
59+
60+
$this->clearCacheForType($type);
5661
}
5762

5863
/**

0 commit comments

Comments
 (0)