Passed
Push — master ( a8b983...5b3176 )
by Adrien
10:48
created

OrderRepository   A

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
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
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\User;
8
use Ecodev\Felix\Repository\LimitedAccessSubQuery;
9
10
class OrderRepository extends AbstractRepository implements LimitedAccessSubQuery
11
{
12
    /**
13
     * Returns pure SQL to get ID of all objects that are accessible to given user.
14
     *
15
     * @param null|User $user
16
     */
17 9
    public function getAccessibleSubQuery(?\Ecodev\Felix\Model\User $user): string
18
    {
19 9
        if (!$user) {
20 1
            return '-1';
21
        }
22
23 8
        if (in_array($user->getRole(), [User::ROLE_FACILITATOR, User::ROLE_ADMINISTRATOR], true)) {
24 3
            return $this->getAllIdsQuery();
25
        }
26
27 5
        return $this->getAllIdsForOwnerQuery($user);
28
    }
29
}
30