Completed
Branch develop-3.0 (63d375)
by Mohamed
02:58
created

MessageQueuer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A queueAdd() 0 4 1
A queueUpdate() 0 9 2
A queueDelete() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Repository\Project\Note;
13
14
use Tinyissue\Model\Message\Queue;
15
use Tinyissue\Model\Project;
16
use Tinyissue\Model\User;
17
18
trait MessageQueuer
19
{
20
    /**
21
     * Insert add note to message queue.
22
     *
23
     * @param Project\Note $note
24
     * @param User         $changeBy
25
     *
26
     * @return void
27
     */
28
    public function queueAdd(Project\Note $note, User $changeBy)
29
    {
30
        return (new Queue())->updater($changeBy)->queue(Queue::ADD_NOTE, $note, $changeBy);
31
    }
32
33
    /**
34
     * Insert update note to message queue.
35
     *
36
     * @param Project\Note $note
37
     * @param User         $changeBy
38
     *
39
     * @return void
40
     */
41
    public function queueUpdate(Project\Note $note, User $changeBy)
42
    {
43
        // Skip message if nothing changed in note
44
        if (!$note->isDirty()) {
45
            return;
46
        }
47
48
        return (new Queue())->updater($changeBy)->queue(Queue::UPDATE_NOTE, $note, $changeBy);
49
    }
50
51
    /**
52
     * Insert delete note to message queue.
53
     *
54
     * @param Project\Note $note
55
     * @param User         $changeBy
56
     *
57
     * @return void
58
     */
59
    public function queueDelete(Project\Note $note, User $changeBy)
60
    {
61
        return (new Queue())->updater($changeBy)->queueDelete(Queue::DELETE_NOTE, $note, $changeBy);
62
    }
63
}
64