| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 13 | public function getAccessibleSubQuery(?\Ecodev\Felix\Model\User $user): string |
|
| 20 | { |
||
| 21 | 13 | if (!$user) { |
|
| 22 | 2 | return '-1'; |
|
| 23 | } |
||
| 24 | |||
| 25 | 11 | if (in_array($user->getRole(), [User::ROLE_RESPONSIBLE, User::ROLE_ADMINISTRATOR], true)) { |
|
| 26 | 8 | 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 | } |
||
| 52 |