getDestination(); return $rocket->setDestination( $this->getDirection($rocket)->parse($this->getPacker($rocket), $response) ); } /** * @throws ContainerException * @throws InvalidConfigException * @throws ServiceNotFoundException */ protected function getDirection(Rocket $rocket): DirectionInterface { $packer = Pay::get($rocket->getDirection()); $packer = is_string($packer) ? Pay::get($packer) : $packer; if (!$packer instanceof DirectionInterface) { throw new InvalidConfigException(Exception::INVALID_PARSER); } return $packer; } /** * @throws ContainerException * @throws InvalidConfigException * @throws ServiceNotFoundException */ protected function getPacker(Rocket $rocket): PackerInterface { $packer = Pay::get($rocket->getPacker()); $packer = is_string($packer) ? Pay::get($packer) : $packer; if (!$packer instanceof PackerInterface) { throw new InvalidConfigException(Exception::INVALID_PACKER); } return $packer; } }