37 lines
968 B
PHP
37 lines
968 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
/**
|
|
* Outcome of a single accommodation's contingent snapshot sync.
|
|
*/
|
|
readonly class ContingentSyncResult
|
|
{
|
|
private function __construct(
|
|
public bool $successful,
|
|
public bool $changed,
|
|
public int $added,
|
|
public int $extended,
|
|
public int $updated,
|
|
public int $removed,
|
|
public ?string $error = null,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* $added counts days newly stored within the horizon the previous run already reached;
|
|
* $extended counts days beyond it, which is the rolling window growing rather than a change.
|
|
*/
|
|
public static function synced(bool $changed, int $added, int $extended, int $updated, int $removed): self
|
|
{
|
|
return new self(true, $changed, $added, $extended, $updated, $removed);
|
|
}
|
|
|
|
public static function failed(string $error): self
|
|
{
|
|
return new self(false, false, 0, 0, 0, 0, $error);
|
|
}
|
|
}
|