$lines */ public function __construct( public readonly array $lines, public readonly ?Party $holder, ) {} /** @return list */ public function orderable(): array { return array_values(array_filter($this->lines, fn (CartLine $line): bool => $line->orderable())); } public function totalCents(): int { return array_sum(array_map(fn (CartLine $line): int => (int) $line->currentPriceCents, $this->orderable())); } public function blocked(): bool { foreach ($this->lines as $line) { if ($line->blocks()) { return true; } } return false; } public function empty(): bool { return $this->orderable() === []; } public function canOrder(): bool { return $this->holder !== null && ! $this->blocked() && ! $this->empty(); } public function digest(): string { $parts = []; foreach ($this->lines as $line) { $parts[] = $line->offer->id.':'.($line->version?->id ?? 0).':'.$line->currentPriceCents.':'.$line->state; } sort($parts); return hash('sha256', ($this->holder?->id ?? 0).'|'.implode(',', $parts)); } }