Test Failed
Push — master ( f49eeb...84602b )
by recca
01:49
created

Every8dMessage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 3
cbo 0
dl 0
loc 83
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A subject() 0 6 1
A content() 0 6 1
A sendTime() 0 6 1
A create() 0 4 1
1
<?php
2
3
namespace Recca0120\Every8d;
4
5
class Every8dMessage
6
{
7
    /**
8
     * The message subject.
9
     *
10
     * @var string
11
     */
12
    public $subject = null;
13
14
    /**
15
     * The message content.
16
     *
17
     * @var string
18
     */
19
    public $content;
20
21
    /**
22
     * The message send time.
23
     *
24
     * @var string
25
     */
26
    public $sendTime;
27
28
    /**
29
     * Create a new message instance.
30
     *
31
     * @param string $content
32
     */
33 5
    public function __construct($content = '')
34
    {
35 5
        $this->content = $content;
36 5
    }
37
38
    /**
39
     * Set the message subject.
40
     *
41
     * @param string $subject
42
     * @return $this
43
     */
44 1
    public function subject($subject)
45
    {
46 1
        $this->subject = $subject;
47
48 1
        return $this;
49
    }
50
51
    /**
52
     * Set the message subject.
53
     *
54
     * @param string $content
55
     * @return $this
56
     */
57 1
    public function content($content)
58
    {
59 1
        $this->content = $content;
60
61 1
        return $this;
62
    }
63
64
    /**
65
     * Set the message send time.
66
     *
67
     * @param \Carbon\Carbon|string $sendTime
68
     * @return $this
69
     */
70 1
    public function sendTime($sendTime)
71
    {
72 1
        $this->sendTime = $sendTime;
0 ignored issues
show
Documentation Bug introduced by
It seems like $sendTime can also be of type object<Carbon\Carbon>. However, the property $sendTime is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
73
74 1
        return $this;
75
    }
76
77
    /**
78
     * Create a new message instance.
79
     *
80
     * @param string $content
81
     * @return static
82
     */
83 1
    public static function create($content)
84
    {
85 1
        return new static($content);
86
    }
87
}
88