44 * An unofficial PHP client library for accessing the official Todoist REST API.
55 *
66 * @author Fabian Beiner <fb@fabianbeiner.de>
7- * @license MIT
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 TodoistLabelsTrait
2626 */
2727 public function getAllLabels ()
2828 {
29- $ result = $ this ->client ->get ('labels? ' . $ this -> tokenQuery );
29+ $ result = $ this ->client ->get ('labels ' );
3030
3131 $ status = $ result ->getStatusCode ();
3232 if ($ status === 204 ) {
@@ -46,13 +46,13 @@ public function getAllLabels()
4646 *
4747 * @return array|bool Array with values of the new label, or false on failure.
4848 */
49- public function createLabel ($ name )
49+ public function createLabel (string $ name )
5050 {
5151 if ( ! mb_strlen ($ name , 'utf8 ' )) {
5252 return false ;
5353 }
5454
55- $ result = $ this ->client ->post ('labels? ' . $ this -> tokenQuery ,
55+ $ result = $ this ->client ->post ('labels ' ,
5656 [
5757 RequestOptions::JSON => ['name ' => trim ($ name )]
5858 ]);
@@ -72,13 +72,13 @@ public function createLabel($name)
7272 *
7373 * @return array|bool Array with values of the label, or false on failure.
7474 */
75- public function getLabel ($ labelId )
75+ public function getLabel (int $ labelId )
7676 {
77- if ($ labelId <= 0 || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
77+ if ( ! $ labelId || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
7878 return false ;
7979 }
8080
81- $ result = $ this ->client ->get ('labels/ ' . $ labelId . ' ? ' . $ this -> tokenQuery );
81+ $ result = $ this ->client ->get ('labels/ ' . $ labelId );
8282
8383 $ status = $ result ->getStatusCode ();
8484 if ($ status === 200 ) {
@@ -96,7 +96,7 @@ public function getLabel($labelId)
9696 *
9797 * @return bool True on success, false on failure.
9898 */
99- public function renameLabel ($ labelId , $ name )
99+ public function renameLabel (int $ labelId , string $ name )
100100 {
101101 return $ this ->updateLabel ($ labelId , $ name );
102102 }
@@ -109,13 +109,13 @@ public function renameLabel($labelId, $name)
109109 *
110110 * @return bool True on success, false on failure.
111111 */
112- public function updateLabel ($ labelId , $ name )
112+ public function updateLabel (int $ labelId , string $ name )
113113 {
114- if ($ labelId <= 0 || ! mb_strlen ($ name , 'utf8 ' ) || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
114+ if ( ! $ labelId || ! mb_strlen ($ name , 'utf8 ' ) || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
115115 return false ;
116116 }
117117
118- $ result = $ this ->client ->post ('labels/ ' . $ labelId . ' ? ' . $ this -> tokenQuery ,
118+ $ result = $ this ->client ->post ('labels/ ' . $ labelId ,
119119 [
120120 RequestOptions::JSON => ['name ' => trim ($ name )]
121121 ]);
@@ -132,13 +132,13 @@ public function updateLabel($labelId, $name)
132132 *
133133 * @return bool True on success, false on failure.
134134 */
135- public function deleteLabel ($ labelId )
135+ public function deleteLabel (int $ labelId )
136136 {
137- if ($ labelId <= 0 || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
137+ if ( ! $ labelId || ! filter_var ($ labelId , FILTER_VALIDATE_INT )) {
138138 return false ;
139139 }
140140
141- $ result = $ this ->client ->delete ('labels/ ' . $ labelId . ' ? ' . $ this -> tokenQuery );
141+ $ result = $ this ->client ->delete ('labels/ ' . $ labelId );
142142
143143 $ status = $ result ->getStatusCode ();
144144
0 commit comments