Files
myep/src/Model/ContentFeed/PageFetchResult.php
T

42 lines
879 B
PHP

<?php
declare(strict_types=1);
namespace App\Model\ContentFeed;
/**
* Outcome of fetching one page's contentUrl.
*
* A 404 or 5xx is a failure of that page, remembered against its `modified`. A timeout is
* transient: the page keeps its stored version and is retried next run.
*/
final readonly class PageFetchResult
{
private function __construct(
public ?string $html,
public ?int $failedStatus,
public bool $transient,
) {
}
public static function ok(string $html): self
{
return new self($html, null, false);
}
public static function failed(int $status): self
{
return new self(null, $status, false);
}
public static function transient(): self
{
return new self(null, null, true);
}
public function isOk(): bool
{
return null !== $this->html;
}
}