1 | <?php |
||
8 | class WunderlistMessage |
||
9 | { |
||
10 | /** @var string */ |
||
11 | protected $title; |
||
12 | |||
13 | /** @var bool */ |
||
14 | protected $completed; |
||
15 | |||
16 | /** @var bool */ |
||
17 | protected $starred; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $recurrenceType; |
||
21 | |||
22 | /** @var string|null */ |
||
23 | protected $due; |
||
24 | |||
25 | /** @var int|null */ |
||
26 | protected $assigneeId; |
||
27 | |||
28 | /** @var int|null */ |
||
29 | protected $recurrenceCount; |
||
30 | |||
31 | const RECURRENCE_TYPE_DAY = 'day'; |
||
32 | const RECURRENCE_TYPE_WEEK = 'week'; |
||
33 | const RECURRENCE_TYPE_MONTH = 'month'; |
||
34 | const RECURRENCE_TYPE_YEAR = 'year'; |
||
35 | |||
36 | /** |
||
37 | * @param string $title |
||
38 | * |
||
39 | * @return static |
||
40 | */ |
||
41 | 1 | public static function create($title) |
|
45 | |||
46 | /** |
||
47 | * @param string $title |
||
48 | */ |
||
49 | 16 | public function __construct($title) |
|
53 | |||
54 | /** |
||
55 | * Set the ticket title. |
||
56 | * |
||
57 | * @param $title |
||
58 | * |
||
59 | * @return $this |
||
60 | */ |
||
61 | 1 | public function title($title) |
|
67 | |||
68 | /** |
||
69 | * Set the ticket assignee_id. |
||
70 | * |
||
71 | * @param int $assigneeId |
||
72 | * |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function assigneeId($assigneeId) |
||
81 | |||
82 | /** |
||
83 | * Set the ticket recurrence_count. |
||
84 | * |
||
85 | * @param int $recurrenceCount |
||
86 | * |
||
87 | * @return $this |
||
88 | */ |
||
89 | public function recurrenceCount($recurrenceCount) |
||
95 | |||
96 | /** |
||
97 | * Set the ticket recurrent_type property. |
||
98 | * |
||
99 | * @param string $recurrenceType |
||
100 | * |
||
101 | * @throws CouldNotCreateMessage |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | 5 | public function recurrenceType($recurrenceType) |
|
106 | { |
||
107 | $allowedRecurrenceTypes = [ |
||
108 | 5 | self::RECURRENCE_TYPE_DAY, |
|
109 | 5 | self::RECURRENCE_TYPE_WEEK, |
|
110 | 5 | self::RECURRENCE_TYPE_MONTH, |
|
111 | 5 | self::RECURRENCE_TYPE_YEAR, |
|
112 | ]; |
||
113 | |||
114 | 5 | if (! in_array($recurrenceType, $allowedRecurrenceTypes)) { |
|
115 | 1 | throw CouldNotCreateMessage::invalidRecurrenceType($recurrenceType); |
|
116 | } |
||
117 | |||
118 | 4 | $this->recurrenceType = $recurrenceType; |
|
119 | |||
120 | 4 | return $this; |
|
121 | } |
||
122 | |||
123 | /** |
||
124 | * Set the ticket as starred. |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | 3 | public function starred() |
|
134 | |||
135 | /** |
||
136 | * Set the ticket as completed. |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | 1 | public function completed() |
|
146 | |||
147 | /** |
||
148 | * Set the card position due date. |
||
149 | * |
||
150 | * @param string|DateTime $due |
||
151 | * |
||
152 | * @return $this |
||
153 | */ |
||
154 | 2 | public function due($due) |
|
164 | |||
165 | /** |
||
166 | * @return array |
||
167 | */ |
||
168 | 15 | public function toArray() |
|
180 | } |
||
181 |