OriginResponseDirection.php 763 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Artful\Direction;
  4. use Psr\Http\Message\ResponseInterface;
  5. use Yansongda\Artful\Contract\DirectionInterface;
  6. use Yansongda\Artful\Contract\PackerInterface;
  7. use Yansongda\Artful\Exception\Exception;
  8. use Yansongda\Artful\Exception\InvalidResponseException;
  9. class OriginResponseDirection implements DirectionInterface
  10. {
  11. /**
  12. * @throws InvalidResponseException
  13. */
  14. public function guide(PackerInterface $packer, ?ResponseInterface $response, array $params = []): ?ResponseInterface
  15. {
  16. if (is_null($response)) {
  17. throw new InvalidResponseException(Exception::RESPONSE_EMPTY, '响应异常: 响应为空,不能进行 direction');
  18. }
  19. return $response;
  20. }
  21. }