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

MessageRepository::getAccessibleSubQuery()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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