Completed
Push — master ( 503797...227dd4 )
by Morteza
03:09
created

ChabokMessage::data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NotificationChannels\Chabok;
4
5
class ChabokMessage
6
{
7
    /** @var string */
8
    protected $user;
9
10
    /** @var string */
11
    protected $content;
12
13
    /** @var array*/
14
    protected $data;
15
16
    /**
17
     * @param string $user
18
     * @return static
19
     */
20 1
    public static function create($user = '')
21
    {
22 1
        return new static($user);
0 ignored issues
show
Documentation introduced by
$user is of type string, but the function expects a array.

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...
23
    }
24
25
    /**
26
     * @param array $user
27
     */
28 6
    public function __construct($user = [])
29
    {
30 6
        $this->user = $user;
0 ignored issues
show
Documentation Bug introduced by
It seems like $user of type array is incompatible with the declared type string of property $user.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31 6
    }
32
33
    /**
34
     * Set the user.
35
     *
36
     * @param $user
37
     *
38
     * @return $this
39
     */
40 1
    public function user($user)
41
    {
42 1
        $this->user = $user;
43
44 1
        return $this;
45
    }
46
47
    /**
48
     * Set the content.
49
     *
50
     * @param $content
51
     *
52
     * @return $this
53
     */
54 2
    public function content($content)
55
    {
56 2
        $this->content = $content;
57
58 2
        return $this;
59
    }
60
61
    /**
62
     * Set the data.
63
     *
64
     * @param array $data
65
     *
66
     * @return $this
67
     */
68 2
    public function data($data)
69
    {
70 2
        $this->data = $data;
71
72 2
        return $this;
73
    }
74
75
    /**
76
     * @return array
77
     */
78 6
    public function toArray()
79
    {
80
        return [
81 6
            'user' => $this->user,
82 6
            'content' => $this->content,
83 6
            'data' => $this->data,
84
        ];
85
    }
86
}
87