mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Reduced the number of arguments in private method
This commit is contained in:
parent
c1906606c6
commit
1bc01057f3
1 changed files with 11 additions and 9 deletions
|
@ -19,6 +19,7 @@ use function sprintf;
|
||||||
class ProcessVisitsCommand extends Command
|
class ProcessVisitsCommand extends Command
|
||||||
{
|
{
|
||||||
public const NAME = 'visit:process';
|
public const NAME = 'visit:process';
|
||||||
|
private const CLEAR_INTERVAL = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var VisitServiceInterface
|
* @var VisitServiceInterface
|
||||||
|
@ -57,17 +58,18 @@ class ProcessVisitsCommand extends Command
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$visits = $this->visitService->getUnlocatedVisits();
|
$visits = $this->visitService->getUnlocatedVisits();
|
||||||
|
|
||||||
foreach ($visits as $visit) {
|
foreach ($visits as $i => $visit) {
|
||||||
$this->processVisit($io, $visit, false);
|
$clear = ($i % self::CLEAR_INTERVAL) === 0;
|
||||||
|
$this->processVisit($output, $visit, $clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->success($this->translator->translate('Finished processing all IPs'));
|
$io->success($this->translator->translate('Finished processing all IPs'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processVisit(SymfonyStyle $io, Visit $visit, bool $clear): void
|
private function processVisit(OutputInterface $output, Visit $visit, bool $clear): void
|
||||||
{
|
{
|
||||||
if (! $visit->hasRemoteAddr()) {
|
if (! $visit->hasRemoteAddr()) {
|
||||||
$io->writeln(
|
$output->writeln(
|
||||||
sprintf('<comment>%s</comment>', $this->translator->translate('Ignored visit with no IP address')),
|
sprintf('<comment>%s</comment>', $this->translator->translate('Ignored visit with no IP address')),
|
||||||
OutputInterface::VERBOSITY_VERBOSE
|
OutputInterface::VERBOSITY_VERBOSE
|
||||||
);
|
);
|
||||||
|
@ -75,9 +77,9 @@ class ProcessVisitsCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$ipAddr = $visit->getRemoteAddr();
|
$ipAddr = $visit->getRemoteAddr();
|
||||||
$io->write(sprintf('%s <fg=blue>%s</>', $this->translator->translate('Processing IP'), $ipAddr));
|
$output->write(sprintf('%s <fg=blue>%s</>', $this->translator->translate('Processing IP'), $ipAddr));
|
||||||
if ($ipAddr === IpAddress::LOCALHOST) {
|
if ($ipAddr === IpAddress::LOCALHOST) {
|
||||||
$io->writeln(
|
$output->writeln(
|
||||||
sprintf(' [<comment>%s</comment>]', $this->translator->translate('Ignored localhost address'))
|
sprintf(' [<comment>%s</comment>]', $this->translator->translate('Ignored localhost address'))
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
@ -86,13 +88,13 @@ class ProcessVisitsCommand extends Command
|
||||||
try {
|
try {
|
||||||
$result = $this->ipLocationResolver->resolveIpLocation($ipAddr);
|
$result = $this->ipLocationResolver->resolveIpLocation($ipAddr);
|
||||||
} catch (WrongIpException $e) {
|
} catch (WrongIpException $e) {
|
||||||
$io->writeln(
|
$output->writeln(
|
||||||
sprintf(
|
sprintf(
|
||||||
' [<fg=red>%s</>]',
|
' [<fg=red>%s</>]',
|
||||||
$this->translator->translate('An error occurred while locating IP. Skipped')
|
$this->translator->translate('An error occurred while locating IP. Skipped')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($io->isVerbose()) {
|
if ($output->isVerbose()) {
|
||||||
$this->getApplication()->renderException($e, $output);
|
$this->getApplication()->renderException($e, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ class ProcessVisitsCommand extends Command
|
||||||
|
|
||||||
$location = new VisitLocation($result);
|
$location = new VisitLocation($result);
|
||||||
$this->visitService->locateVisit($visit, $location, $clear);
|
$this->visitService->locateVisit($visit, $location, $clear);
|
||||||
$io->writeln(sprintf(
|
$output->writeln(sprintf(
|
||||||
' [<info>' . $this->translator->translate('Address located at "%s"') . '</info>]',
|
' [<info>' . $this->translator->translate('Address located at "%s"') . '</info>]',
|
||||||
$location->getCountryName()
|
$location->getCountryName()
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue