Completed
Push — develop ( b779dc...323e79 )
by Mohamed
06:59
created

QueueTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 43
ccs 5
cts 8
cp 0.625
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\Model\Traits\Project\Note;
13
14
use Tinyissue\Model\Project\Note;
15
use Tinyissue\Model\Message;
16
use Tinyissue\Model\Message\Queue;
17
18
/**
19
 * QueueTrait is trait class for adding method to insert records into a queue.
20
 *
21
 * @author Mohamed Alsharaf <[email protected]>
22
 */
23
trait QueueTrait
24
{
25
    /**
26
     * Insert add note to message queue.
27
     *
28
     * @param Note $note
29
     *
30
     * @return void
31
     */
32 2
    public function queueAdd(Note $note)
33
    {
34 2
        return (new Message\Queue())->queue(Queue::ADD_NOTE, $note, auth()->user());
0 ignored issues
show
Documentation introduced by
auth()->user() is of type object<Illuminate\Contra...h\Authenticatable>|null, but the function expects a integer|object<Tinyissue\Model\User>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
    }
36
37
    /**
38
     * Insert update note to message queue.
39
     *
40
     * @param Note $note
41
     *
42
     * @return void
43
     */
44 1
    public function queueUpdate(Note $note)
45
    {
46
        // Skip message if nothing changed in note
47 1
        if (!$note->isDirty()) {
48
            return;
49
        }
50
51 1
        return (new Message\Queue())->queue(Queue::UPDATE_NOTE, $note, auth()->user());
0 ignored issues
show
Documentation introduced by
auth()->user() is of type object<Illuminate\Contra...h\Authenticatable>|null, but the function expects a integer|object<Tinyissue\Model\User>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52
    }
53
54
    /**
55
     * Insert delete note to message queue.
56
     *
57
     * @param Note $note
58
     *
59
     * @return void
60
     */
61
    public function queueDelete(Note $note)
62
    {
63
        return (new Message\Queue())->queueDelete(Queue::DELETE_NOTE, $note, auth()->user());
0 ignored issues
show
Documentation introduced by
auth()->user() is of type object<Illuminate\Contra...h\Authenticatable>|null, but the function expects a integer|object<Tinyissue\Model\User>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
    }
65
}
66