id = $id; $this->status = $status; $this->label = $label; $this->message = $message; $this->remedy = $remedy; $this->copy = $copy; } /** * Nothing wrong here. * * @param string $id Check id. * @param string $label Check label. * @param string $message What was observed. * @return self */ public static function ok( string $id, string $label, string $message ): self { return new self( $id, self::OK, $label, $message ); } /** * Something worth knowing, which this probe cannot prove either way. * * @param string $id Check id. * @param string $label Check label. * @param string $message What was observed. * @param string $remedy What to do about it. * @param string $copy Paste-able text. * @return self */ public static function warning( string $id, string $label, string $message, string $remedy = '', string $copy = '' ): self { return new self( $id, self::WARNING, $label, $message, $remedy, $copy ); } /** * Demonstrably broken. * * @param string $id Check id. * @param string $label Check label. * @param string $message What was observed. * @param string $remedy What to do about it. * @param string $copy Paste-able text. * @return self */ public static function fail( string $id, string $label, string $message, string $remedy = '', string $copy = '' ): self { return new self( $id, self::FAIL, $label, $message, $remedy, $copy ); } /** * Context, asserting nothing. * * @param string $id Check id. * @param string $label Check label. * @param string $message What was observed. * @param string $remedy Optional follow-up. * @return self */ public static function info( string $id, string $label, string $message, string $remedy = '' ): self { return new self( $id, self::INFO, $label, $message, $remedy ); } /** * A check that did not run, naming what has to be fixed first. * * Reported rather than omitted: a silently shorter list reads as "nothing * else to check", which is the opposite of the truth. * * @param string $id Identifier of the skipped check. * @param string $label Its label. * @param array $blockers Labels of the failed prerequisites. * @return self */ public static function skipped( string $id, string $label, array $blockers ): self { return new self( $id, self::SKIPPED, $label, sprintf( /* translators: %s: comma-separated list of check names that failed */ __( 'Not run — fix %s first.', 'acrossai-mcp-manager' ), implode( ', ', $blockers ) ) ); } /** * Stable identifier. * * @return string */ public function id(): string { return $this->id; } /** * One of the class constants. * * @return string */ public function status(): string { return $this->status; } /** * Human-readable check name. * * @return string */ public function label(): string { return $this->label; } /** * Whether this result blocks dependent checks. * * @return bool */ public function is_fail(): bool { return self::FAIL === $this->status; } /** * Flat shape for the REST response. * * @return array */ public function to_array(): array { return array( 'id' => $this->id, 'status' => $this->status, 'label' => $this->label, 'message' => $this->message, 'remedy' => $this->remedy, 'copy' => $this->copy, ); } }