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
|
1 |
|
public static function create($name = '') |
30
|
|
|
{ |
31
|
1 |
|
return new static($name); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $name |
36
|
|
|
*/ |
37
|
15 |
|
public function __construct($name = '') |
38
|
|
|
{ |
39
|
15 |
|
$this->name = $name; |
40
|
15 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Set the card name. |
44
|
|
|
* |
45
|
|
|
* @param $name |
46
|
|
|
* |
47
|
|
|
* @return $this |
48
|
|
|
*/ |
49
|
1 |
|
public function name($name) |
50
|
|
|
{ |
51
|
1 |
|
$this->name = $name; |
52
|
|
|
|
53
|
1 |
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Set the card description. |
58
|
|
|
* |
59
|
|
|
* @param $description |
60
|
|
|
* |
61
|
|
|
* @return $this |
62
|
|
|
*/ |
63
|
4 |
|
public function description($description) |
64
|
|
|
{ |
65
|
4 |
|
$this->description = $description; |
66
|
|
|
|
67
|
4 |
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Set the card position. |
72
|
|
|
* |
73
|
|
|
* @param string|int $position |
74
|
|
|
* |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
1 |
|
public function position($position) |
78
|
|
|
{ |
79
|
1 |
|
$this->position = $position; |
80
|
|
|
|
81
|
1 |
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Set the card position to 'top'. |
86
|
|
|
* |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
4 |
|
public function top() |
90
|
|
|
{ |
91
|
4 |
|
$this->position = 'top'; |
92
|
|
|
|
93
|
4 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set the card position to 'bottom'. |
98
|
|
|
* |
99
|
|
|
* @return $this |
100
|
|
|
*/ |
101
|
1 |
|
public function bottom() |
102
|
|
|
{ |
103
|
1 |
|
$this->position = 'bottom'; |
104
|
|
|
|
105
|
1 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Set the card position due date. |
110
|
|
|
* |
111
|
|
|
* @param string|DateTime $due |
112
|
|
|
* |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
2 |
|
public function due($due) |
116
|
|
|
{ |
117
|
2 |
|
if (! $due instanceof DateTime) { |
118
|
1 |
|
$due = new DateTime($due); |
119
|
1 |
|
} |
120
|
|
|
|
121
|
2 |
|
$this->due = $due->format(DateTime::ATOM); |
122
|
|
|
|
123
|
2 |
|
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
|
3 |
|
public function comments($comments) |
134
|
|
|
{ |
135
|
3 |
|
if (! is_array($comments)) { |
136
|
1 |
|
$this->comments = [$comments]; |
137
|
1 |
|
} else { |
138
|
2 |
|
$this->comments = $comments; |
139
|
|
|
} |
140
|
|
|
|
141
|
3 |
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Add a comment to the card. |
146
|
|
|
* |
147
|
|
|
* @param array $comments |
|
|
|
|
148
|
|
|
* |
149
|
|
|
* @return $this |
150
|
|
|
*/ |
151
|
1 |
|
public function comment($comment) |
152
|
|
|
{ |
153
|
1 |
|
$this->comments[] = $comment; |
154
|
|
|
|
155
|
1 |
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Get comments to add to the card. |
160
|
|
|
* |
161
|
|
|
* @return array|null |
162
|
|
|
*/ |
163
|
6 |
|
public function getComments() |
164
|
|
|
{ |
165
|
6 |
|
return $this->comments; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return array |
170
|
|
|
*/ |
171
|
12 |
|
public function toArray() |
172
|
|
|
{ |
173
|
|
|
return [ |
174
|
12 |
|
'name' => $this->name, |
175
|
12 |
|
'desc' => $this->description, |
176
|
12 |
|
'pos' => $this->position, |
177
|
12 |
|
'due' => $this->due, |
178
|
12 |
|
]; |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|
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 methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.