diff --git a/lib/PushEvent.php b/lib/PushEvent.php index d3c0cda..1e40b3e 100644 --- a/lib/PushEvent.php +++ b/lib/PushEvent.php @@ -211,11 +211,11 @@ class PushEvent implements \JsonSerializable { /** * Sets the URL for comparing the revisions. - * @param UriInterface|string|null $value The URL for comparing the revisions. + * @param UriInterface|null $value The URL for comparing the revisions. * @return $this This instance. */ - function setCompareUrl($value): self { - $this->compareUrl = is_string($value) ? new Uri($value) : $value; + function setCompareUrl(?UriInterface $value): self { + $this->compareUrl = $value; return $this; } diff --git a/lib/models/PayloadCommit.php b/lib/models/PayloadCommit.php index 703d699..c358203 100644 --- a/lib/models/PayloadCommit.php +++ b/lib/models/PayloadCommit.php @@ -73,8 +73,8 @@ class PayloadCommit implements \JsonSerializable { return (new static(isset($map->id) && is_string($map->id) ? $map->id : '', isset($map->message) && is_string($map->message) ? $map->message : '')) ->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($map->author) : null) ->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($map->committer) : null) - ->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? $map->timestamp : null) - ->setUrl(isset($map->url) && is_string($map->url) ? $map->url : null) + ->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : null) + ->setUrl(isset($map->url) && is_string($map->url) ? new Uri($map->url) : null) ->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($map->verification) : null); } @@ -182,21 +182,21 @@ class PayloadCommit implements \JsonSerializable { /** * Sets the commit date. - * @param \DateTime|string|null $value The new commit date. + * @param \DateTime|null $value The new commit date. * @return $this This instance. */ - function setTimestamp($value): self { - $this->timestamp = is_string($value) ? new \DateTime($value) : $value; + function setTimestamp(?\DateTime $value): self { + $this->timestamp = $value; return $this; } /** * Sets the URL to the commit's history. - * @param UriInterface|string|null $value The new commit URL. + * @param UriInterface|null $value The new commit URL. * @return $this This instance. */ - function setUrl($value): self { - $this->url = is_string($value) ? new Uri($value) : $value; + function setUrl(?UriInterface $value): self { + $this->url = $value; return $this; } diff --git a/lib/models/Repository.php b/lib/models/Repository.php index ef64f79..2302187 100644 --- a/lib/models/Repository.php +++ b/lib/models/Repository.php @@ -393,21 +393,21 @@ class Repository implements \JsonSerializable { /** * Sets the HTTP-based URL for cloning this repository. - * @param UriInterface|string|null $value The new URL for cloning this repository. + * @param UriInterface|null $value The new URL for cloning this repository. * @return $this This instance. */ - function setCloneUrl($value): self { - $this->cloneUrl = is_string($value) ? new Uri($value) : $value; + function setCloneUrl(?UriInterface $value): self { + $this->cloneUrl = $value; return $this; } /** * Sets the date the repository was created. - * @param \DateTime|string|null $value The new date of creation. + * @param \DateTime|null $value The new date of creation. * @return $this This instance. */ - function setCreatedAt($value): self { - $this->createdAt = is_string($value) ? new \DateTime($value) : $value; + function setCreatedAt(?\DateTime $value): self { + $this->createdAt = $value; return $this; } @@ -473,11 +473,11 @@ class Repository implements \JsonSerializable { /** * Sets the Gitea URL of this repository. - * @param UriInterface|string|null $value The new Gitea URL. + * @param UriInterface|null $value The new Gitea URL. * @return $this This instance. */ - function setHtmlUrl($value): self { - $this->htmlUrl = is_string($value) ? new Uri($value) : $value; + function setHtmlUrl(?UriInterface $value): self { + $this->htmlUrl = $value; return $this; } @@ -563,11 +563,11 @@ class Repository implements \JsonSerializable { /** * Sets the SSH-based URL for cloning this repository. - * @param UriInterface|string|null $value The new URL for cloning this repository. + * @param UriInterface|null $value The new URL for cloning this repository. * @return $this This instance. */ - function setSshUrl($value): self { - $this->sshUrl = is_string($value) ? new Uri($value) : $value; + function setSshUrl(?UriInterface $value): self { + $this->sshUrl = $value; return $this; } @@ -583,11 +583,11 @@ class Repository implements \JsonSerializable { /** * Sets the date the repository was updated. - * @param \DateTime|string|null $value The new date of update. + * @param \DateTime|null $value The new date of update. * @return $this This instance. */ - function setUpdatedAt($value): self { - $this->updatedAt = is_string($value) ? new \DateTime($value) : $value; + function setUpdatedAt(?\DateTime $value): self { + $this->updatedAt = $value; return $this; } @@ -603,11 +603,11 @@ class Repository implements \JsonSerializable { /** * Sets the URL of the repository website. - * @param UriInterface|string|null $value The new repository website. + * @param UriInterface|null $value The new repository website. * @return $this This instance. */ - function setWebsite($value): self { - $this->website = is_string($value) ? new Uri($value) : $value; + function setWebsite(?UriInterface $value): self { + $this->website = $value; return $this; } } diff --git a/lib/models/TrackedTime.php b/lib/models/TrackedTime.php index 4dc27c1..964ec3a 100644 --- a/lib/models/TrackedTime.php +++ b/lib/models/TrackedTime.php @@ -58,7 +58,7 @@ class TrackedTime implements \JsonSerializable { */ static function fromJson(object $map): self { return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->time) && is_int($map->time) ? $map->time : 0)) - ->setCreatedAt(isset($map->created) && is_string($map->created) ? $map->created : null) + ->setCreatedAt(isset($map->created) && is_string($map->created) ? new \DateTime($map->created) : null) ->setIssueId(isset($map->issue_id) && is_int($map->issue_id) ? $map->issue_id : -1) ->setUserId(isset($map->user_id) && is_int($map->user_id) ? $map->user_id : -1); } @@ -119,11 +119,11 @@ class TrackedTime implements \JsonSerializable { /** * Sets the date the entry was created. - * @param \DateTime|string|null $value The new date of creation. + * @param \DateTime|null $value The new date of creation. * @return $this This instance. */ - function setCreatedAt($value): self { - $this->createdAt = is_string($value) ? new \DateTime($value) : $value; + function setCreatedAt(?\DateTime $value): self { + $this->createdAt = $value; return $this; } diff --git a/lib/models/User.php b/lib/models/User.php index 25168e4..d33255c 100644 --- a/lib/models/User.php +++ b/lib/models/User.php @@ -66,7 +66,7 @@ class User implements \JsonSerializable { */ static function fromJson(object $map): self { return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->login) && is_string($map->login) ? $map->login : '')) - ->setAvatarUrl(isset($map->avatar_url) && is_string($map->avatar_url) ? $map->avatar_url : null) + ->setAvatarUrl(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null) ->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '') ->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '') ->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : ''); @@ -137,11 +137,11 @@ class User implements \JsonSerializable { /** * Sets the URL of the avatar image. - * @param UriInterface|string|null $value The new avatar URL. + * @param UriInterface|null $value The new avatar URL. * @return $this This instance. */ - function setAvatarUrl($value): self { - $this->avatarUrl = is_string($value) ? new Uri($value) : $value; + function setAvatarUrl(?UriInterface $value): self { + $this->avatarUrl = $value; return $this; }