getRDBRepository(EmailAddress::ENTITY_TYPE); if (!$repository instanceof EmailAddressRepository) { throw new RuntimeException(); } $this->internalRepository = $repository; } /** * Find entities by an email address. * * @param string $address An email address. * @return Entity[] */ public function find(string $address): array { $emailAddress = $this->repository->getByAddress($address); if (!$emailAddress) { return []; } return $this->internalRepository->getEntityListByAddressId($emailAddress->getId()); } /** * Find a first entity by an email address. * * @param string $address An email address. * @param string[] $order An order entity type list. */ public function findOne(string $address, ?array $order = null): ?Entity { if ($order) { $this->internalRepository->getEntityByAddress($address, null, $order); } return $this->internalRepository->getEntityByAddress($address); } }