1000) { throw new \InvalidArgumentException( sprintf('Priority must be between -1000 and 1000, got %d', $value) ); } } public static function critical(): self { return new self(self::CRITICAL); } public static function high(): self { return new self(self::HIGH); } public static function normal(): self { return new self(self::NORMAL); } public static function low(): self { return new self(self::LOW); } public static function deferred(): self { return new self(self::DEFERRED); } public function isHigherThan(self $other): bool { return $this->value > $other->value; } public function isLowerThan(self $other): bool { return $this->value < $other->value; } public function equals(self $other): bool { return $this->value === $other->value; } public function isCritical(): bool { return $this->value >= self::CRITICAL; } public function isHigh(): bool { return $this->value >= self::HIGH && $this->value < self::CRITICAL; } public function isNormal(): bool { return $this->value > self::LOW && $this->value < self::HIGH; } public function isLow(): bool { return $this->value > self::DEFERRED && $this->value <= self::LOW; } public function isDeferred(): bool { return $this->value <= self::DEFERRED; } public function toString(): string { return match (true) { $this->isCritical() => 'critical', $this->isHigh() => 'high', $this->isNormal() => 'normal', $this->isLow() => 'low', $this->isDeferred() => 'deferred', default => sprintf('custom(%d)', $this->value) }; } }