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