Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

43 рядки
898B

  1. <?php
  2. namespace Framework\Testing;
  3. use Framework\App;
  4. use Framework\Http\Response;
  5. class TestResponse
  6. {
  7. private Response $response;
  8. public function __construct(Response $response)
  9. {
  10. $this->response = $response;
  11. }
  12. public function isRedirecting(): bool
  13. {
  14. return $this->response->type() === Response::REDIRECT;
  15. }
  16. public function redirectingTo(): ?string
  17. {
  18. return $this->response->redirect();
  19. }
  20. public function follow(): static
  21. {
  22. while ($this->isRedirecting()) {
  23. $_SERVER['REQUEST_METHOD'] = 'GET';
  24. $_SERVER['REQUEST_URI'] = $this->redirectingTo();
  25. $this->response = App::getInstance()->run();
  26. }
  27. return $this;
  28. }
  29. public function __call(string $method, array $parameters = []): mixed
  30. {
  31. return $this->response->$method(...$parameters);
  32. }
  33. }

Powered by TurnKey Linux.