| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | private function getCustomerOrder($apiKey): CustomerOrder |
||
| 31 | { |
||
| 32 | $em = $this->doctrine->getEntityManager(); |
||
| 33 | /** @var CustomerOrderRepository $repository */ |
||
| 34 | $customerOrderRepository = $em->getRepository('AppBundle:CustomerOrder'); |
||
| 35 | $customer = $em->getRepository('AppBundle:Customer')->findOneBy(['apiKey' => $apiKey]); |
||
| 36 | $order = $customerOrderRepository->findLastOpenOrder($customer); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Creating order if isn't exist |
||
| 40 | */ |
||
| 41 | if (!$order) { |
||
| 42 | $order = new CustomerOrder($customer); |
||
| 43 | $em->persist($order); |
||
| 44 | } |
||
| 45 | return $order; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |