IsParticipantThreadSpecification::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\Messaging\Specifications;
12
13
use Miliooo\Messaging\Model\ThreadInterface;
14
use Miliooo\Messaging\User\ParticipantInterface;
15
16
/**
17
 * This checks if the given participant is participant of the given thread.
18
 *
19
 * This can be used when deciding if a participant can see a given thread.
20
 * Since in most cases it does not make sense to not allow a participant to see a thread where he is part of.
21
 *
22
 * @author Michiel Boeckaert <[email protected]>
23
 */
24
class IsParticipantThreadSpecification
25
{
26
    /**
27
     * Checks if the given participant is part of the participants of the thread
28
     *
29
     * @param ParticipantInterface $participant The user that we check for
30
     * @param ThreadInterface      $thread       The thread that we check
31
     *
32
     * @return boolean true if participant can see the thread, false otherwise
33
     */
34
    public function isSatisfiedBy(ParticipantInterface $participant, ThreadInterface $thread)
35
    {
36
        if ($thread->isParticipant($participant)) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return $thread->isParticipant($participant);.
Loading history...
37
            return true;
38
        }
39
40
        return false;
41
    }
42
}
43