ReasonPhraseLocation.php 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
  3. use GuzzleHttp\Command\Guzzle\Parameter;
  4. use GuzzleHttp\Command\ResultInterface;
  5. use Psr\Http\Message\ResponseInterface;
  6. /**
  7. * Extracts the reason phrase of a response into a result field
  8. */
  9. class ReasonPhraseLocation extends AbstractLocation
  10. {
  11. /**
  12. * Set the name of the location
  13. *
  14. * @param string $locationName
  15. */
  16. public function __construct($locationName = 'reasonPhrase')
  17. {
  18. parent::__construct($locationName);
  19. }
  20. /**
  21. * @param ResultInterface $result
  22. * @param ResponseInterface $response
  23. * @param Parameter $param
  24. * @return ResultInterface
  25. */
  26. public function visit(
  27. ResultInterface $result,
  28. ResponseInterface $response,
  29. Parameter $param
  30. ) {
  31. $result[$param->getName()] = $param->filter(
  32. $response->getReasonPhrase()
  33. );
  34. return $result;
  35. }
  36. }