Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit f72eeb7

Browse files
committed
Re-indented PhpfastcacheCommand code
1 parent d50e1b8 commit f72eeb7

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

src/Command/PhpfastcacheCommand.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
namespace Phpfastcache\Bundle\Command;
1919

2020
use Phpfastcache\Bundle\Service\Phpfastcache;
21-
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
2221
use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException;
22+
use Symfony\Component\Console\Command\Command;
2323
use Symfony\Component\Console\Input\InputArgument;
2424
use Symfony\Component\Console\Input\InputInterface;
2525
use Symfony\Component\Console\Output\OutputInterface;
2626
use Symfony\Component\Console\Style\SymfonyStyle;
27-
use Symfony\Component\Console\Command\Command;
2827

2928
class PhpfastcacheCommand extends Command
3029
{
@@ -54,14 +53,13 @@ public function __construct(Phpfastcache $phpfastcache, $parameters)
5453
protected function configure()
5554
{
5655
$this
57-
->setName('phpfastcache:clear')
58-
->setDescription('Clear phpfastcache cache')
59-
->addArgument(
60-
'driver',
61-
InputArgument::OPTIONAL,
62-
'Cache name to clear'
63-
)
64-
;
56+
->setName('phpfastcache:clear')
57+
->setDescription('Clear phpfastcache cache')
58+
->addArgument(
59+
'driver',
60+
InputArgument::OPTIONAL,
61+
'Cache name to clear'
62+
);
6563
}
6664

6765
/**
@@ -76,48 +74,47 @@ protected function execute(InputInterface $input, OutputInterface $output)
7674

7775
$driver = $input->getArgument('driver');
7876

79-
$output->writeln("<bg=yellow;fg=red>Clearing cache operation can take a while, please be patient...</>");
77+
$output->writeln('<bg=yellow;fg=red>Clearing cache operation can take a while, please be patient...</>');
8078

81-
$callback = function($name) use ($output, &$failedInstances)
82-
{
83-
try{
79+
$callback = function ($name) use ($output, &$failedInstances) {
80+
try {
8481
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
8582
$output->writeln("<fg=yellow>Clearing instance {$name} cache...</>");
8683
}
8784
$this->phpfastcache->get($name)->clear();
8885
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
8986
$output->writeln("<fg=green>Cache instance {$name} cleared</>");
9087
}
91-
}catch (PhpfastcacheDriverCheckException $e){
88+
} catch (PhpfastcacheDriverCheckException $e) {
9289
$failedInstances[] = $name;
9390
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
94-
$output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>");
95-
}else{
91+
$output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . '<bg=red;options=bold>' . $e->getMessage() . '</>');
92+
} else {
9693
$output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>");
9794
}
9895
}
9996
};
10097

10198
$caches = $this->parameters;
10299

103-
if($driver) {
104-
if(\array_key_exists($driver, $caches['drivers'])){
100+
if ($driver) {
101+
if (\array_key_exists($driver, $caches[ 'drivers' ])) {
105102
$callback($driver);
106-
if(!\count($failedInstances)){
103+
if (!\count($failedInstances)) {
107104
$io->success("Cache instance {$driver} cleared");
108-
}else{
105+
} else {
109106
$io->error("Cache instance {$driver} not cleared");
110107
}
111-
}else{
108+
} else {
112109
$io->error("Cache instance {$driver} does not exists");
113110
}
114111
} else {
115-
foreach($caches['drivers'] as $name => $parameters) {
112+
foreach ($caches[ 'drivers' ] as $name => $parameters) {
116113
$callback($name);
117114
}
118-
if(!\count($failedInstances)){
115+
if (!\count($failedInstances)) {
119116
$io->success('All caches instances got cleared');
120-
}else{
117+
} else {
121118
$io->success('Almost all caches instances got cleared, except these: ' . \implode(', ', $failedInstances));
122119
}
123120
}

0 commit comments

Comments
 (0)