setCode($code); $this->setMessage($message); $this->setResource($resource); } /** * Get the error code * * @return int */ public function getCode(): int { return $this->code; } /** * Set the error code * * @param int $code Set to zeroo or a negative value to clear errors * * @return void */ public function setCode(int $code): void { if ($code <= 0) { $code = 0; $this->setMessage(''); $this->setResource(''); } $this->code = $code; } /** * Get the error message * * @return string */ public function getMessage(): string { return $this->message; } /** * Set the error message * * @param string $message The error message to set * * @return void */ public function setMessage(string $message): void { $this->message = $message; } /** * Get the URI of the resource throwing the error * * @return string */ public function getResource(): string { return $this->resource; } /** * Set the URI of the resource throwing the error * * @param string $resource * * @return void */ public function setResource(string $resource): void { $this->resource = $resource; } /** * Do we actually have an error? * * @return bool */ public function isError(): bool { return ($this->code > 0) || !empty($this->message); } }