/** * @return OrderInterface * * @throws \RuntimeException */ private function getLastOrder() { $customer = $this->sharedStorage->get('user')->getCustomer(); $orders = $this->orderRepository->findByCustomer($customer); $lastOrder = end($orders); if (false === $lastOrder) { throw new \RuntimeException(sprintf('There is no last order for %s', $customer->getFullName())); } return $lastOrder; }