static-php-cli/src/SPC/doctor/CheckResult.php

49 lines
1.0 KiB
PHP
Raw Normal View History

2023-04-22 21:23:12 +08:00
<?php
declare(strict_types=1);
namespace SPC\doctor;
class CheckResult
{
2023-06-28 18:38:14 +08:00
public function __construct(private bool $ok, private ?string $message = null, private string $fix_item = '', private array $fix_params = [])
2023-04-22 21:23:12 +08:00
{
}
public static function fail(string $message, string $fix_item = '', array $fix_params = []): CheckResult
{
2023-06-28 18:38:14 +08:00
return new static(false, $message, $fix_item, $fix_params);
2023-04-22 21:23:12 +08:00
}
2023-06-28 18:38:14 +08:00
public static function ok(?string $message = null): CheckResult
2023-04-22 21:23:12 +08:00
{
2023-06-28 18:38:14 +08:00
return new static(true, $message);
2023-04-22 21:23:12 +08:00
}
2023-06-28 18:38:14 +08:00
public function getMessage(): ?string
2023-04-22 21:23:12 +08:00
{
return $this->message;
}
public function getFixItem(): string
{
return $this->fix_item;
}
public function getFixParams(): array
{
return $this->fix_params;
}
public function isOK(): bool
{
2023-06-28 18:38:14 +08:00
return $this->ok;
2023-04-22 21:23:12 +08:00
}
2023-04-30 12:42:19 +08:00
public function setFixItem(string $fix_item = '', array $fix_params = [])
{
$this->fix_item = $fix_item;
$this->fix_params = $fix_params;
}
2023-04-22 21:23:12 +08:00
}