$facts recorded facts (duplicates of an earlier contribution are not recorded again) */ public function __construct(public readonly array $facts = []) {} /** * @return list field keys with the given outcome */ public function fields(string $outcome): array { return array_values(array_map(fn (CaseFact $fact): string => $fact->field, array_filter($this->facts, fn (CaseFact $fact): bool => $fact->outcome === $outcome))); } public function anyApplied(): bool { return $this->fields(CaseFact::APPLIED) !== []; } public function needsReview(): bool { return $this->fields(CaseFact::CONFLICT) !== [] || $this->fields(CaseFact::CHANGE_REQUEST) !== []; } public function isEmpty(): bool { return $this->facts === []; } /** * Plain words for the landlord, e.g. for a notification. */ public function summary(): string { $parts = []; foreach ([CaseFact::APPLIED => 'übernommen', CaseFact::CONFIRMED => 'bestätigt', CaseFact::CONFLICT => 'weichen ab (zur Prüfung)', CaseFact::CHANGE_REQUEST => 'Änderungswunsch (zur Prüfung)', CaseFact::REJECTED => 'nicht verwendbar'] as $outcome => $label) { $fields = $this->fields($outcome); if ($fields !== []) { $parts[] = implode(', ', CaseRequirements::labels($fields)).' '.$label; } } return $parts === [] ? 'Keine neuen Angaben.' : implode(' · ', $parts); } }