setCommunicator($communicator); parent::__construct($name); } protected function configure() { $this->addArgument('mailbox_id', InputArgument::REQUIRED, 'Mailbox ID to grab emails'); } protected Communicator $communicator; public function getCommunicator(): Communicator { return $this->communicator; } public function setCommunicator(Communicator $communicator): Grab { $this->communicator = $communicator; return $this; } protected function grabMessages(int $mailbox_id): int { $response = $this->getCommunicator()->get("/mailbox/{$mailbox_id}/grab"); $body = $response->getBody()->getContents(); if (trim($body) === '') { return 0; } return json_decode($body)->messages->count; } public function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $mailbox_id = $input->getArgument('mailbox_id'); $io->title("Grabbing Messages for Mailbox ID {$mailbox_id}"); $io->section('Grabbing Messages'); $count = $this->grabMessages($mailbox_id); $io->info("Found {$count} messages"); $io->success('Done.'); return Command::SUCCESS; } }