Completed
Pull Request — master (#7)
by
unknown
05:10
created

src/TrelloMessage.php (1 issue)

Look for PHPDoc comments for non-existent parameters and make alternative suggestion.

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace NotificationChannels\Trello;
4
5
use DateTime;
6
7
class TrelloMessage
8
{
9
    /** @var string */
10
    protected $name;
11
12
    /** @var string */
13
    protected $description;
14
15
    /** @var string|int */
16
    protected $position;
17
18
    /** @var string|null */
19
    protected $due;
20
21
    /** @var array|null */
22
    protected $comments;
23
24
    /**
25
     * @param string $name
26
     *
27
     * @return static
28
     */
29
    public static function create($name = '')
30
    {
31
        return new static($name);
32
    }
33
34
    /**
35
     * @param string $name
36
     */
37
    public function __construct($name = '')
38
    {
39
        $this->name = $name;
40
    }
41
42
    /**
43
     * Set the card name.
44
     *
45
     * @param $name
46
     *
47
     * @return $this
48
     */
49
    public function name($name)
50
    {
51
        $this->name = $name;
52
53
        return $this;
54
    }
55
56
    /**
57
     * Set the card description.
58
     *
59
     * @param $description
60
     *
61
     * @return $this
62
     */
63
    public function description($description)
64
    {
65
        $this->description = $description;
66
67
        return $this;
68
    }
69
70
    /**
71
     * Set the card position.
72
     *
73
     * @param string|int $position
74
     *
75
     * @return $this
76
     */
77
    public function position($position)
78
    {
79
        $this->position = $position;
80
81
        return $this;
82
    }
83
84
    /**
85
     * Set the card position to 'top'.
86
     *
87
     * @return $this
88
     */
89
    public function top()
90
    {
91
        $this->position = 'top';
92
93
        return $this;
94
    }
95
96
    /**
97
     * Set the card position to 'bottom'.
98
     *
99
     * @return $this
100
     */
101
    public function bottom()
102
    {
103
        $this->position = 'bottom';
104
105
        return $this;
106
    }
107
108
    /**
109
     * Set the card position due date.
110
     *
111
     * @param string|DateTime $due
112
     *
113
     * @return $this
114
     */
115
    public function due($due)
116
    {
117
        if (!$due instanceof DateTime) {
118
            $due = new DateTime($due);
119
        }
120
121
        $this->due = $due->format(DateTime::ATOM);
122
123
        return $this;
124
    }
125
126
    /**
127
     * Set the cards comments from array or string
128
     *
129
     * @param array|string $comments
130
     *
131
     * @return $this
132
     */
133
    public function comments($comments)
134
    {
135
        if (!is_array($comments)) {
136
            $this->comments = [$comments];
137
        } else {
138
            $this->comments = $comments;
139
        }
140
141
        return $this;
142
    }
143
144
    /**
145
     * Add a comment to the card
146
     *
147
     * @param array $comments
0 ignored issues
show
There is no parameter named $comments. Did you maybe mean $comment?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
148
     *
149
     * @return $this
150
     */
151
    public function comment($comment)
152
    {
153
        $this->comments[] = $comment;
154
155
        return $this;
156
    }
157
158
    /**
159
     * Get comments to add to the card
160
     *
161
     * @return array|null
162
     */
163
    public function getComments()
164
    {
165
        return $this->comments;
166
    }
167
168
    /**
169
     * @return array
170
     */
171
    public function toArray()
172
    {
173
        return [
174
            'name' => $this->name,
175
            'desc' => $this->description,
176
            'pos' => $this->position,
177
            'due' => $this->due,
178
        ];
179
    }
180
}
181