Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5.5069 |
Changes | 1 | ||
Bugs | 0 | Features | 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 | $webTypes = [ProductTypeType::BOTH, ProductTypeType::DIGITAL]; |
|
32 | 1 | if ($user->getWebTemporaryAccess() || in_array($user->getSubscriptionType(), $webTypes, true)) { |
|
33 | $webTypesSql = implode(',', array_map(function (string $val): string { |
||
34 | return $this->getEntityManager()->getConnection()->quote($val); |
||
35 | }, $webTypes)); |
||
36 | |||
37 | return ' |
||
38 | SELECT file.id FROM file |
||
39 | INNER JOIN product p ON file.product_id = p.id AND p.is_active AND p.type IN (' . $webTypesSql . ') |
||
40 | '; |
||
41 | } |
||
42 | |||
43 | 1 | return '-1'; |
|
44 | } |
||
46 |