*/ public array $contacts = []; private int $nextId = 1; public function findForCustomer(int $customerId, int $contactId): ?CustomerContact { $contact = $this->contacts[$contactId] ?? null; return $contact !== null && $contact->customerId() === $customerId ? clone $contact : null; } public function save(CustomerContact $contact): CustomerContact { $id = $contact->id() ?? $this->nextId++; $stored = CustomerContact::reconstitute( $id, $contact->customerId(), $contact->name(), $contact->title(), $contact->phone(), $contact->email(), $contact->note(), ); $this->contacts[$id] = $stored; return clone $stored; } public function delete(CustomerContact $contact): void { unset($this->contacts[$contact->id()]); } public function existsForCustomer(int $customerId): bool { foreach ($this->contacts as $contact) { if ($contact->customerId() === $customerId) { return true; } } return false; } }