connection = $connection; $this->serializer = $serializer ?? new PhpSerializer(); } /** * {@inheritdoc} */ public function get(): iterable { return ($this->receiver ?? $this->getReceiver())->get(); } /** * {@inheritdoc} */ public function ack(Envelope $envelope): void { ($this->receiver ?? $this->getReceiver())->ack($envelope); } /** * {@inheritdoc} */ public function reject(Envelope $envelope): void { ($this->receiver ?? $this->getReceiver())->reject($envelope); } /** * {@inheritdoc} */ public function send(Envelope $envelope): Envelope { return ($this->sender ?? $this->getSender())->send($envelope); } private function getReceiver(): BeanstalkReceiver { return $this->receiver = new BeanstalkReceiver($this->connection, $this->serializer); } private function getSender(): BeanstalkSender { return $this->sender = new BeanstalkSender($this->connection, $this->serializer); } }