MessageQueryTrait::unread()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.name/
9
 * @copyright Copyright (c) 2016 vistart
10
 * @license https://vistart.name/license/
11
 */
12
13
namespace vistart\Models\traits;
14
15
use vistart\Models\traits\MutualQueryTrait;
16
17
/**
18
 * This trait is used for building message query class for message model.
19
 *
20
 * @version 2.0
21
 * @author vistart <[email protected]>
22
 */
23
trait MessageQueryTrait
24
{
25
    use MutualQueryTrait;
26
27
    /**
28
     * Specify unread message.
29
     * @return \static $this
30
     */
31 2
    public function unread()
32
    {
33 2
        $model = $this->noInitModel;
0 ignored issues
show
Bug introduced by
The property noInitModel does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34 2
        return $this->likeCondition($model->initDatetime(), $model->readAtAttribute);
0 ignored issues
show
Bug introduced by
It seems like likeCondition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
35
    }
36
37
    /**
38
     * Specify read message.
39
     * @return \static $this
40
     */
41 2
    public function read()
42
    {
43 2
        $model = $this->noInitModel;
44 2
        return $this->likeCondition($model->initDatetime(), $model->readAtAttribute, 'not in');
0 ignored issues
show
Bug introduced by
It seems like likeCondition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
45
    }
46
47
    /**
48
     * Specify unreceived message.
49
     * @return \static $this
50
     */
51 2
    public function unreceived()
52
    {
53 2
        $model = $this->noInitModel;
54 2
        return $this->likeCondition($model->initDatetime(), $model->receivedAtAttribute);
0 ignored issues
show
Bug introduced by
It seems like likeCondition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
55
    }
56
57
    /**
58
     * Specify received message.
59
     * @return \static $this
60
     */
61 2
    public function received()
62
    {
63 2
        $model = $this->noInitModel;
64 2
        return $this->likeCondition($model->initDatetime(), $model->receivedAtAttribute, 'not in');
0 ignored issues
show
Bug introduced by
It seems like likeCondition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
65
    }
66
}
67