response = $response; } public function handle(iRequest $request): iResponse { return is_callable($this->response) ? ($this->response)($request) : $this->response; } }; } protected function getRequest( Method|string $method = Method::GET, string $uri = '/', array $post = [], array $query = [], array $headers = [], array $cookies = [], array $files = [], array $server = [], iStream|null $body = null ): iRequest { $factory = new Psr17Factory(); $creator = new ServerRequestCreator($factory, $factory, $factory, $factory); return $creator->fromArrays( server: array_replace_recursive([ 'REQUEST_METHOD' => is_string($method) ? $method : $method->value, 'SCRIPT_FILENAME' => realpath(__DIR__ . '/../../public/index.php'), 'REMOTE_ADDR' => '127.0.0.1', 'REQUEST_URI' => $uri, 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => 80, 'HTTP_USER_AGENT' => 'WatchState/0.0', ], $server), headers: array_replace_recursive($server, [ 'Accept' => 'application/json', 'Authorization' => 'Bearer api_test_token', ], $headers), cookie: $cookies, get: $query, post: $post, files: $files, body: $body, ); } }