Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
19 | 14 | public function getAccessibleSubQuery(?\Ecodev\Felix\Model\User $user): string |
|
20 | { |
||
21 | 14 | if (!$user) { |
|
22 | 2 | return '-1'; |
|
23 | } |
||
24 | |||
25 | 12 | if (in_array($user->getRole(), [User::ROLE_RESPONSIBLE, User::ROLE_ADMINISTRATOR], true)) { |
|
26 | 9 | return $this->getAllIdsQuery(); |
|
27 | } |
||
28 | |||
29 | 3 | if ($user->getOwner()) { |
|
30 | 1 | $id = $user->getOwner()->getId(); |
|
31 | } else { |
||
32 | 2 | $id = $user->getId(); |
|
33 | } |
||
34 | |||
35 | return 'SELECT transaction_line.id FROM transaction_line |
||
36 | JOIN account ON transaction_line.debit_id = account.id OR transaction_line.credit_id = account.id |
||
37 | 3 | WHERE account.owner_id = ' . $id; |
|
38 | } |
||
60 |