33 * Todoist PHP API Library
44 * An unofficial PHP client library for accessing the official Todoist REST API.
55 *
6- * @author Balazs Csaba <[email protected] > 7- * @license MIT
6+ * @author Fabian Beiner <[email protected] > 7+ * @license https://opensource.org/licenses/MIT MIT
88 * @link https://github.com/FabianBeiner/Todoist-PHP-API-Library
99 */
1010
@@ -26,7 +26,7 @@ trait TodoistTasksTrait
2626 */
2727 public function getAllTasks ()
2828 {
29- $ result = $ this ->client ->get ('tasks? ' . $ this -> tokenQuery );
29+ $ result = $ this ->client ->get ('tasks ' );
3030
3131 $ status = $ result ->getStatusCode ();
3232 if ($ status === 204 ) {
@@ -47,7 +47,7 @@ public function getAllTasks()
4747 *
4848 * @return array|bool Array with values of the new task, or false on failure.
4949 */
50- public function createTask ($ content , array $ options = [])
50+ public function createTask (string $ content , array $ options = [])
5151 {
5252 if ( ! mb_strlen ($ content , 'utf8 ' )) {
5353 return false ;
@@ -56,9 +56,10 @@ public function createTask($content, array $options = [])
5656 if ($ options ) {
5757 unset($ options ['content ' ]);
5858 }
59- $ result = $ this ->client ->post ('tasks? ' . $ this -> tokenQuery ,
59+ $ result = $ this ->client ->post ('tasks ' ,
6060 [
61- RequestOptions::JSON => array_merge (['content ' => trim ($ content )], $ options ),
61+ RequestOptions::JSON => array_merge (['content ' => trim ($ content )],
62+ $ options ),
6263 ]);
6364
6465 $ status = $ result ->getStatusCode ();
@@ -76,13 +77,13 @@ public function createTask($content, array $options = [])
7677 *
7778 * @return array|bool Array with values of the task, or false on failure.
7879 */
79- public function getTask ($ taskId )
80+ public function getTask (int $ taskId )
8081 {
81- if ($ taskId <= 0 || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
82+ if ( ! $ taskId || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
8283 return false ;
8384 }
8485
85- $ result = $ this ->client ->get ('tasks/ ' . $ taskId . ' ? ' . $ this -> tokenQuery );
86+ $ result = $ this ->client ->get ('tasks/ ' . $ taskId );
8687
8788 $ status = $ result ->getStatusCode ();
8889 if ($ status === 200 ) {
@@ -101,7 +102,7 @@ public function getTask($taskId)
101102 *
102103 * @return array|bool Array with values of the new task, or false on failure.
103104 */
104- public function updateTask ($ taskId , $ content , array $ options = [])
105+ public function updateTask (int $ taskId , string $ content , array $ options = [])
105106 {
106107 if ( ! mb_strlen ($ content , 'utf8 ' )) {
107108 return false ;
@@ -110,9 +111,10 @@ public function updateTask($taskId, $content, array $options = [])
110111 if ($ options ) {
111112 unset($ options ['content ' ]);
112113 }
113- $ result = $ this ->client ->post ('tasks/ ' . $ taskId . ' ? ' . $ this -> tokenQuery ,
114+ $ result = $ this ->client ->post ('tasks/ ' . $ taskId ,
114115 [
115- RequestOptions::JSON => array_merge (['content ' => trim ($ content )], $ options ),
116+ RequestOptions::JSON => array_merge (['content ' => trim ($ content )],
117+ $ options ),
116118 ]);
117119
118120 $ status = $ result ->getStatusCode ();
@@ -130,13 +132,13 @@ public function updateTask($taskId, $content, array $options = [])
130132 *
131133 * @return bool True on success, false on failure.
132134 */
133- public function closeTask ($ taskId )
135+ public function closeTask (int $ taskId )
134136 {
135- if ($ taskId <= 0 || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
137+ if ( ! $ taskId || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
136138 return false ;
137139 }
138140
139- $ result = $ this ->client ->get ('tasks/ ' . $ taskId . '/close ' . ' ? ' . $ this -> tokenQuery );
141+ $ result = $ this ->client ->get ('tasks/ ' . $ taskId . '/close ' );
140142 $ status = $ result ->getStatusCode ();
141143
142144 return ($ status === 200 || $ status === 204 );
@@ -149,13 +151,13 @@ public function closeTask($taskId)
149151 *
150152 * @return bool True on success, false on failure.
151153 */
152- public function reopenTask ($ taskId )
154+ public function reopenTask (int $ taskId )
153155 {
154- if ($ taskId <= 0 || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
156+ if ( ! $ taskId || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
155157 return false ;
156158 }
157159
158- $ result = $ this ->client ->get ('tasks/ ' . $ taskId . '/reopen ' . ' ? ' . $ this -> tokenQuery );
160+ $ result = $ this ->client ->get ('tasks/ ' . $ taskId . '/reopen ' );
159161 $ status = $ result ->getStatusCode ();
160162
161163 return ($ status === 200 || $ status === 204 );
@@ -168,13 +170,13 @@ public function reopenTask($taskId)
168170 *
169171 * @return bool True on success, false on failure.
170172 */
171- public function deleteTask ($ taskId )
173+ public function deleteTask (int $ taskId )
172174 {
173- if ($ taskId <= 0 || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
175+ if ( ! $ taskId || ! filter_var ($ taskId , FILTER_VALIDATE_INT )) {
174176 return false ;
175177 }
176178
177- $ result = $ this ->client ->delete ('tasks/ ' . $ taskId . ' ? ' . $ this -> tokenQuery );
179+ $ result = $ this ->client ->delete ('tasks/ ' . $ taskId );
178180 $ status = $ result ->getStatusCode ();
179181
180182 return ($ status === 200 || $ status === 204 );
0 commit comments