setCommunicator($communicator); parent::__construct($name); } protected Communicator $communicator; public function getCommunicator(): Communicator { return $this->communicator; } public function setCommunicator(Communicator $communicator): DecryptPdf { $this->communicator = $communicator; return $this; } protected function getAttachments(): array { $response = $this->getCommunicator()->get('/attachments/pending'); return \Safe\json_decode($response->getBody()->getContents())->attachments; } protected function decrypt(string $attachment): bool { $response = $this->getCommunicator()->put('/attachments/decrypt', ['attachments' => [$attachment]]); return \Safe\json_decode($response->getBody()->getContents())->status; } public function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Decrypt Attachments'); $io->section('Grabbing Attachments'); $attachments = $this->getAttachments(); $io->text('Found ' . count($attachments) . ' attachments.'); $io->section('Decrypting Attachments'); foreach ($attachments as $attachment) { $status = $this->decrypt($attachment); if ($status) { $io->success("{$attachment} decrypted correctly."); } else { $io->error("Problem decrypting {$attachment}."); } } $io->success('Done.'); return Command::SUCCESS; } }