Skip to content

Commit 8a27a63

Browse files
committed
Improved Projects Trait.
1 parent 8398e75 commit 8a27a63

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/FabianBeiner/Todoist/TodoistProjectsTrait.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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 TodoistProjectsTrait
2626
*/
2727
public function getAllProjects()
2828
{
29-
$result = $this->client->get('projects?' . $this->tokenQuery);
29+
$result = $this->client->get('projects');
3030

3131
$status = $result->getStatusCode();
3232
if ($status === 204) {
@@ -46,13 +46,13 @@ public function getAllProjects()
4646
*
4747
* @return array|bool Array with values of the new project, or false on failure.
4848
*/
49-
public function createProject($name)
49+
public function createProject(string $name)
5050
{
5151
if ( ! mb_strlen($name, 'utf8')) {
5252
return false;
5353
}
5454

55-
$result = $this->client->post('projects?' . $this->tokenQuery,
55+
$result = $this->client->post('projects',
5656
[
5757
RequestOptions::JSON => ['name' => trim($name)]
5858
]);
@@ -72,13 +72,13 @@ public function createProject($name)
7272
*
7373
* @return array|bool Array with values of the project, or false on failure.
7474
*/
75-
public function getProject($projectId)
75+
public function getProject(int $projectId)
7676
{
77-
if ($projectId <= 0 || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
77+
if ( ! $projectId || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
7878
return false;
7979
}
8080

81-
$result = $this->client->get('projects/' . $projectId . '?' . $this->tokenQuery);
81+
$result = $this->client->get('projects/' . $projectId);
8282

8383
$status = $result->getStatusCode();
8484
if ($status === 200) {
@@ -96,7 +96,7 @@ public function getProject($projectId)
9696
*
9797
* @return bool True on success, false on failure.
9898
*/
99-
public function renameProject($projectId, $name)
99+
public function renameProject(int $projectId, string $name)
100100
{
101101
return $this->updateProject($projectId, $name);
102102
}
@@ -109,13 +109,13 @@ public function renameProject($projectId, $name)
109109
*
110110
* @return bool True on success, false on failure.
111111
*/
112-
public function updateProject($projectId, $name)
112+
public function updateProject(int $projectId, string $name)
113113
{
114-
if ($projectId <= 0 || ! mb_strlen($name, 'utf8') || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
114+
if ( ! $projectId || ! mb_strlen($name, 'utf8') || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
115115
return false;
116116
}
117117

118-
$result = $this->client->post('projects/' . $projectId . '?' . $this->tokenQuery,
118+
$result = $this->client->post('projects/' . $projectId,
119119
[
120120
RequestOptions::JSON => ['name' => trim($name)]
121121
]);
@@ -132,13 +132,13 @@ public function updateProject($projectId, $name)
132132
*
133133
* @return bool True on success, false on failure.
134134
*/
135-
public function deleteProject($projectId)
135+
public function deleteProject(int $projectId)
136136
{
137-
if ($projectId <= 0 || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
137+
if ( ! $projectId || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
138138
return false;
139139
}
140140

141-
$result = $this->client->delete('projects/' . $projectId . '?' . $this->tokenQuery);
141+
$result = $this->client->delete('projects/' . $projectId);
142142

143143
$status = $result->getStatusCode();
144144

0 commit comments

Comments
 (0)