CanSeeThreadSpecification::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
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\User\ParticipantInterface;
14
use Miliooo\Messaging\Model\ThreadInterface;
15
16
/**
17
 * CanSeeThreadSpecification.
18
 *
19
 * The can see thread specification is responsible for deciding if the given
20
 * participant can see the given thread.
21
 *
22
 * The default implementation is that they have to be participant of that thread.
23
 * Since it would not make much sense to not let the participant see that thread
24
 *
25
 * One of the many reasons to  extend could be to check if the participant
26
 * has a certain role... (eg ROLE_SUPER_ADMIN)
27
 *
28
 * @author Michiel Boeckaert <[email protected]>
29
 */
30
class CanSeeThreadSpecification
31
{
32
    /**
33
     * Checks if the given participant can see the given thread.
34
     *
35
     * @param ParticipantInterface $participant The user that we check for
36
     * @param ThreadInterface      $thread      The thread that we check
37
     *
38
     * @return boolean true if participant can see the thread, false otherwise
39
     */
40
    public function isSatisfiedBy(ParticipantInterface $participant, ThreadInterface $thread)
41
    {
42
        $participantThread = $this->getIsParticipantThreadSpecification();
43
44
        return $participantThread->isSatisfiedBy($participant, $thread);
45
    }
46
47
    /**
48
     * Gets the participantThreadSpecification.
49
     *
50
     * Helper function for unit tests
51
     *
52
     * @return IsParticipantThreadSpecification
53
     */
54
    protected function getIsParticipantThreadSpecification()
55
    {
56
        $participantThread = new IsParticipantThreadSpecification();
57
58
        return $participantThread;
59
    }
60
}
61