visitsTracker = $visitsTracker; } public function configure() { $this->setName('shortcode:visits') ->setDescription('Returns the detailed visits information for provided short code') ->addArgument('shortCode', InputArgument::REQUIRED, 'The short code which visits we want to get'); } public function interact(InputInterface $input, OutputInterface $output) { $shortCode = $input->getArgument('shortCode'); if (! empty($shortCode)) { return; } /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new Question( 'A short code was not provided. Which short code do you want to use?: ' ); $shortCode = $helper->ask($input, $output, $question); if (! empty($shortCode)) { $input->setArgument('shortCode', $shortCode); } } public function execute(InputInterface $input, OutputInterface $output) { $shortCode = $input->getArgument('shortCode'); $visits = $this->visitsTracker->info($shortCode); $table = new Table($output); $table->setHeaders([ 'Referer', 'Date', 'Temote Address', 'User agent', ]); foreach ($visits as $row) { $table->addRow(array_values($row->jsonSerialize())); } $table->render(); } }