Failed Conditions
Push — master ( 481507...cfb9d3 )
by
unknown
12:41
created

MessageRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAccessibleSubQuery() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Repository;
6
7
use Application\Model\User;
8
9
class MessageRepository extends AbstractRepository implements LimitedAccessSubQueryInterface
10
{
11
    /**
12
     * Returns pure SQL to get ID of all objects that are accessible to given user.
13
     *
14
     * @param null|User $user
15
     *
16
     * @return string
17
     */
18
    public function getAccessibleSubQuery(?User $user): string
19
    {
20
        if ($user) {
21
            return 'SELECT id FROM message WHERE recipient_id = ' . $user->getId();
22
        }
23
24
        return '-1';
25
    }
26
}
27