|null The decoded JSON object, or null. */ public $json; /** * @var string The transport error, when there was one. */ public $error; /** * @var string The raw body, exactly as received: a signed answer is verified on these bytes, before decoding. */ public $body; /** * @var string The X-Cortex-Response-Signature header, or '' when the answer carries none. */ public $signature; /** * @param array|null $json Decoded body. */ public function __construct( int $status, ?array $json, string $error = '', string $body = '', string $signature = '' ) { $this->status = $status; $this->json = $json; $this->error = $error; $this->body = $body; $this->signature = $signature; if ( $status >= 200 && $status < 300 ) { $this->kind = self::OK; } elseif ( 0 === $status || 408 === $status || 429 === $status || $status >= 500 ) { $this->kind = self::RETRY; } else { $this->kind = self::REFUSED; } } public function ok(): bool { return self::OK === $this->kind; } /** * For log lines: the transport error or the HTTP status. Never the body. */ public function describe(): string { return 0 === $this->status ? $this->error : 'HTTP ' . $this->status; } }