public function getById(PaymentId $paymentId) : Payment { $payment = $this->entityManager->getRepository(Payment::class)->findOneBy(['id.id' => $paymentId]); if (is_null($payment)) { throw new PaymentNotFoundException(); } return $payment; }