| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | class SubscriptionRepository extends DoctrineCrudRepository implements SubscriptionRepositoryInterface |
||
| 24 | { |
||
| 25 | public function hasActiveSubscription(CustomerInterface $customer): bool |
||
| 26 | { |
||
| 27 | try { |
||
| 28 | $this->getOneActiveSubscriptionForCustomer($customer); |
||
| 29 | } catch (NoEntityFoundException $exception) { |
||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | return true; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getOneActiveSubscriptionForCustomer(CustomerInterface $customer): Subscription |
||
| 37 | { |
||
| 38 | $subscription = $this->entityRepository->findOneBy(['customer' => $customer, 'active' => true]); |
||
| 39 | |||
| 40 | if (!$subscription instanceof Subscription) { |
||
| 41 | throw new NoEntityFoundException(); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $subscription; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getAllForCustomer(CustomerInterface $customer): array |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getAllActiveForCustomer(CustomerInterface $customer): array |
||
| 55 | } |
||
| 56 | } |
||
| 57 |