AccountingDocumentRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAccessibleSubQuery() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Repository;
6
7
use Application\Model\AccountingDocument;
8
use Application\Model\User;
9
10
use Ecodev\Felix\Repository\LimitedAccessSubQuery;
11
12
/**
13
 * @extends AbstractRepository<AccountingDocument>
14
 */
15
class AccountingDocumentRepository extends AbstractRepository implements LimitedAccessSubQuery
16
{
17
    /**
18
     * Returns pure SQL to get ID of all objects that are accessible to given user.
19
     *
20
     * @param null|User $user
21
     */
22 10
    public function getAccessibleSubQuery(?\Ecodev\Felix\Model\User $user): string
23
    {
24 10
        if (!$user) {
25 1
            return '-1';
26
        }
27
28 9
        if (in_array($user->getRole(), [User::ROLE_ACCOUNTING_VERIFICATOR, User::ROLE_RESPONSIBLE, User::ROLE_ADMINISTRATOR], true)) {
29 6
            return '';
30
        }
31
32 3
        return $this->getAllIdsForFamilyQuery($user);
33
    }
34
}
35