| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.0187 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 4 | public function getAccessibleSubQuery(?User $user): string |
|
| 22 | { |
||
| 23 | 4 | if (!$user) { |
|
| 24 | 1 | return '-1'; |
|
| 25 | } |
||
| 26 | |||
| 27 | 3 | if (in_array($user->getRole(), [User::ROLE_FACILITATOR, User::ROLE_ADMINISTRATOR], true)) { |
|
| 28 | 2 | return $this->getAllIdsQuery(); |
|
| 29 | } |
||
| 30 | |||
| 31 | 1 | if (!$user->getWebTemporaryAccess() && !in_array($user->getSubscriptionType(), [ProductTypeType::BOTH, ProductTypeType::DIGITAL], true)) { |
|
| 32 | $webTypesSql = '(' . |
||
| 33 | 1 | $this->getEntityManager()->getConnection()->quote(ProductTypeType::BOTH) . ', ' . |
|
| 34 | 1 | $this->getEntityManager()->getConnection()->quote(ProductTypeType::DIGITAL) . |
|
| 35 | 1 | ')'; |
|
| 36 | |||
| 37 | return ' |
||
| 38 | SELECT file.id FROM file |
||
| 39 | 1 | INNER JOIN product p ON file.product_id = p.id AND p.is_active and p.type IN ' . $webTypesSql . ' |
|
| 40 | '; |
||
| 41 | } |
||
| 42 | |||
| 43 | return ''; |
||
| 44 | } |
||
| 46 |