ThreadProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findThreadById() 0 6 2
A findThreadForParticipant() 0 6 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\ThreadProvider;
12
13
use Miliooo\Messaging\Repository\ThreadRepositoryInterface;
14
use Miliooo\Messaging\User\ParticipantInterface;
15
16
/**
17
 * The thread provider is responsible for providing threads
18
 *
19
 * @author Michiel Boeckaert <[email protected]>
20
 */
21
class ThreadProvider implements ThreadProviderInterface
22
{
23
    /**
24
     * A thread repository instance
25
     * @var ThreadRepositoryInterface
26
     */
27
    protected $threadRepository;
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param ThreadRepositoryInterface $threadRepository
33
     */
34
    public function __construct(ThreadRepositoryInterface $threadRepository)
35
    {
36
        $this->threadRepository = $threadRepository;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function findThreadById($threadId)
43
    {
44
        $thread = $this->threadRepository->findThread($threadId);
45
46
        return is_object($thread) ? $thread : null;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function findThreadForParticipant($threadId, ParticipantInterface $participant)
53
    {
54
        $thread = $this->threadRepository->findThreadForParticipant($threadId, $participant);
55
56
        return is_object($thread) ? $thread : null;
57
    }
58
}
59