Skip to content

Commit 42b0cf5

Browse files
authored
fix: remove nullability from id fields (#104)
1 parent 06b22b3 commit 42b0cf5

23 files changed

Lines changed: 108 additions & 98 deletions

src/Api/Ticket/AttachmentApis.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use SupportPal\ApiClient\Exception\MissingIdentifierException;
1111
use SupportPal\ApiClient\Model\Collection\Collection;
1212
use SupportPal\ApiClient\Model\Ticket\Attachment;
13+
use TypeError;
1314

1415
use function array_map;
1516

@@ -52,11 +53,13 @@ public function getAttachment(int $attachmentId): Attachment
5253
*/
5354
public function downloadAttachment(Attachment $attachment): StreamInterface
5455
{
55-
if ($attachment->getId() === null) {
56+
try {
57+
$attachmentId = $attachment->getId();
58+
} catch (TypeError $typeError) {
5659
throw new MissingIdentifierException('missing attachment identifier');
5760
}
5861

59-
return $this->getApiClient()->downloadAttachment($attachment->getId())->getBody();
62+
return $this->getApiClient()->downloadAttachment($attachmentId)->getBody();
6063
}
6164

6265
/**

src/Api/Ticket/TicketApis.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket;
1212
use SupportPal\ApiClient\Model\Ticket\Ticket;
1313
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
14+
use TypeError;
1415

1516
use function array_map;
1617

@@ -54,11 +55,13 @@ public function getTicket(int $ticketId): Ticket
5455
*/
5556
public function updateTicket(Ticket $ticket, array $data): Ticket
5657
{
57-
if ($ticket->getId() === null) {
58+
try {
59+
$ticketId = $ticket->getId();
60+
} catch (TypeError $typeError) {
5861
throw new MissingIdentifierException('missing ticket identifier');
5962
}
6063

61-
$response = $this->getApiClient()->updateTicket($ticket->getId(), $data);
64+
$response = $this->getApiClient()->updateTicket($ticketId, $data);
6265

6366
return $this->createTicket($this->decodeBody($response)['data']);
6467
}

src/Api/User/UserApis.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use SupportPal\ApiClient\Model\User\Request\CreateUser;
1212
use SupportPal\ApiClient\Model\User\User;
1313
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
14+
use TypeError;
1415

1516
use function array_map;
1617

@@ -54,11 +55,13 @@ public function getUser(int $userId): User
5455
*/
5556
public function updateUser(User $user, array $data): User
5657
{
57-
if ($user->getId() === null) {
58+
try {
59+
$userId = $user->getId();
60+
} catch (TypeError $typeError) {
5861
throw new MissingIdentifierException('missing user identifier');
5962
}
6063

61-
$response = $this->getApiClient()->updateUser($user->getId(), $data);
64+
$response = $this->getApiClient()->updateUser($userId, $data);
6265

6366
return $this->createUser($this->decodeBody($response)['data']);
6467
}

src/Model/Core/Brand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class Brand extends BaseModel
203203
private $defaultTimezone;
204204

205205
/**
206-
* @var int|null
206+
* @var int
207207
* @SerializedName("id")
208208
*/
209209
private $id;
@@ -777,18 +777,18 @@ public function setDefaultTimezone(string $defaultTimezone): self
777777
}
778778

779779
/**
780-
* @return int|null
780+
* @return int
781781
*/
782-
public function getId(): ?int
782+
public function getId(): int
783783
{
784784
return $this->id;
785785
}
786786

787787
/**
788-
* @param int|null $id
788+
* @param int $id
789789
* @return self
790790
*/
791-
public function setId(?int $id): self
791+
public function setId(int $id): self
792792
{
793793
$this->id = $id;
794794

src/Model/Department/Department.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Department extends BaseModel
5656
private $notifyEmailTicket;
5757

5858
/**
59-
* @var int|null
59+
* @var int
6060
* @SerializedName("id")
6161
*/
6262
private $id;
@@ -289,18 +289,18 @@ public function setNotifyEmailTicket(bool $notifyEmailTicket): self
289289
}
290290

291291
/**
292-
* @return int|null
292+
* @return int
293293
*/
294-
public function getId(): ?int
294+
public function getId(): int
295295
{
296296
return $this->id;
297297
}
298298

299299
/**
300-
* @param int|null $id
300+
* @param int $id
301301
* @return self
302302
*/
303-
public function setId(?int $id): self
303+
public function setId(int $id): self
304304
{
305305
$this->id = $id;
306306

src/Model/Department/Email.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Email extends BaseModel
1515
{
1616
/**
17-
* @var int|null
17+
* @var int
1818
* @SerializedName("id")
1919
*/
2020
private $id;
@@ -116,18 +116,18 @@ class Email extends BaseModel
116116
private $authMech;
117117

118118
/**
119-
* @return int|null
119+
* @return int
120120
*/
121-
public function getId(): ?int
121+
public function getId(): int
122122
{
123123
return $this->id;
124124
}
125125

126126
/**
127-
* @param int|null $id
127+
* @param int $id
128128
* @return self
129129
*/
130-
public function setId(?int $id): self
130+
public function setId(int $id): self
131131
{
132132
$this->id = $id;
133133

src/Model/SelfService/Article.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ class Article extends BaseModel
159159
private $totalRating;
160160

161161
/**
162-
* @return int|null
162+
* @return int
163163
*/
164-
public function getId(): ?int
164+
public function getId(): int
165165
{
166166
return $this->id;
167167
}

src/Model/SelfService/Comment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Comment extends BaseModel
2020
];
2121

2222
/**
23-
* @var int|null
23+
* @var int
2424
* @SerializedName("id")
2525
*/
2626
private $id;
@@ -122,9 +122,9 @@ class Comment extends BaseModel
122122
private $rating;
123123

124124
/**
125-
* @return int|null
125+
* @return int
126126
*/
127-
public function getId(): ?int
127+
public function getId(): int
128128
{
129129
return $this->id;
130130
}

src/Model/SelfService/Type.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Type extends BaseModel
2727
private $icon;
2828

2929
/**
30-
* @var int|null
30+
* @var int
3131
* @SerializedName("id")
3232
*/
3333
private $id;
@@ -154,18 +154,18 @@ public function setIcon(?string $icon): self
154154
}
155155

156156
/**
157-
* @return int|null
157+
* @return int
158158
*/
159-
public function getId(): ?int
159+
public function getId(): int
160160
{
161161
return $this->id;
162162
}
163163

164164
/**
165-
* @param int|null $id
165+
* @param int $id
166166
* @return self
167167
*/
168-
public function setId(?int $id): self
168+
public function setId(int $id): self
169169
{
170170
$this->id = $id;
171171

src/Model/Shared/CustomField.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ abstract class CustomField extends BaseModel
7373
private $dependsOnOptionId;
7474

7575
/**
76-
* @var int|null
76+
* @var int
7777
* @SerializedName("id")
7878
*/
7979
private $id;
@@ -272,18 +272,18 @@ public function setDependsOnOptionId(?int $dependsOnOptionId): self
272272
}
273273

274274
/**
275-
* @return int|null
275+
* @return int
276276
*/
277-
public function getId(): ?int
277+
public function getId(): int
278278
{
279279
return $this->id;
280280
}
281281

282282
/**
283-
* @param int|null $id
283+
* @param int $id
284284
* @return self
285285
*/
286-
public function setId(?int $id): self
286+
public function setId(int $id): self
287287
{
288288
$this->id = $id;
289289

0 commit comments

Comments
 (0)