diff --git a/src/Reflect/Method.php b/src/Reflect/Method.php new file mode 100644 index 0000000..00d4c67 --- /dev/null +++ b/src/Reflect/Method.php @@ -0,0 +1,13 @@ +status, $this->body] = $response; + + $this->ok = $this->is_ok(); + } + + // A boolean indicating whether the response was successful (status in the range 200 – 299) or not + public function is_ok(): bool { + return $this->status >= 200 && $this->status < 300; + } + + // Parse JSON from response body and return as PHP array + public function json(bool $assoc = true): array { + return json_decode($this->body, $assoc); + } + + // Return response body as-is + public function text() { + return $this->body; + } + } \ No newline at end of file