| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/east-point.site/public/wp-content/plugins/staatic/src/Publication/ |
Upload File : |
<?php
declare(strict_types=1);
namespace Staatic\WordPress\Publication;
use InvalidArgumentException;
use RuntimeException;
final class PublicationStatus
{
/**
* @var string
*/
private $status;
public const STATUS_PENDING = 'pending';
public const STATUS_IN_PROGRESS = 'in_progress';
public const STATUS_FINISHED = 'finished';
public const STATUS_CANCELED = 'canceled';
public const STATUS_FAILED = 'failed';
private function __construct(string $status)
{
$this->status = $status;
}
public function __toString()
{
return $this->status;
}
/**
* @param string $status
*/
public static function create($status): self
{
if (!in_array(
$status,
[self::STATUS_PENDING,
self::STATUS_IN_PROGRESS,
self::STATUS_FINISHED,
self::STATUS_CANCELED,
self::STATUS_FAILED
])) {
throw new InvalidArgumentException(sprintf('Invalid status supplied: %s', $status));
}
return new self($status);
}
public function status(): string
{
return $this->status;
}
public function isPending(): bool
{
return $this->status === self::STATUS_PENDING;
}
public function isCanceled(): bool
{
return $this->status === self::STATUS_CANCELED;
}
public function isInProgress(): bool
{
return $this->status === self::STATUS_IN_PROGRESS;
}
public function isFinished(): bool
{
return $this->status === self::STATUS_FINISHED;
}
public function isFailed(): bool
{
return $this->status === self::STATUS_FAILED;
}
public function label(): string
{
$labels = self::labels();
if (!isset($labels[$this->status])) {
throw new RuntimeException(sprintf('Unknown status %s', $this->status));
}
return $labels[$this->status];
}
public static function labels(): array
{
return [
self::STATUS_PENDING => __('Pending', 'staatic'),
self::STATUS_IN_PROGRESS => __('In Progress', 'staatic'),
self::STATUS_FINISHED => __('Finished', 'staatic'),
self::STATUS_CANCELED => __('Canceled', 'staatic'),
self::STATUS_FAILED => __('Failed', 'staatic')
];
}
}