From 66618304225dd4dffc2dd3118a13d38d0dadc852 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 21 Nov 2024 20:17:54 +0000 Subject: [PATCH] Added email fields to V1User and also reordering to match with API output. --- VERSION | 2 +- src/V1/Users/V1User.php | 48 ++++++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 0c62199..ee1372d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 diff --git a/src/V1/Users/V1User.php b/src/V1/Users/V1User.php index f6a06e3..432695e 100644 --- a/src/V1/Users/V1User.php +++ b/src/V1/Users/V1User.php @@ -1,7 +1,7 @@ name; } + /** + * Gets user e-mail address. + * + * Will be blank regardless of anything if the identify:email scope isn't granted. + * + * @return string + */ + public function getEMailAddress(): string { + return $this->email; + } + /** * Whether a raw 24-bit RGB colour is present. * @@ -260,18 +273,19 @@ final class V1User { return new static( isset($info->id) && is_string($info->id) ? $info->id : '', isset($info->name) && is_string($info->name) ? $info->name : '', + isset($info->email) && is_string($info->email) ? $info->email : '', isset($info->colour_raw) && is_int($info->colour_raw) ? $info->colour_raw : null, isset($info->colour_css) && is_string($info->colour_css) ? $info->colour_css : '', isset($info->rank) && is_int($info->rank) ? $info->rank : 0, isset($info->country_code) && is_string($info->country_code) ? $info->country_code : '', - isset($info->avatar_urls) && is_array($info->avatar_urls) ? array_map(fn(mixed $item) => (is_object($item) ? V1UserAvatar::decode($item) : V1UserAvatar::empty()), $info->avatar_urls) : [], - isset($info->profile_url) && is_string($info->profile_url) ? $info->profile_url : '', + isset($info->roles) && is_array($info->roles) ? $info->roles : [], // @phpstan-ignore-line + isset($info->is_super) && is_bool($info->is_super) ? $info->is_super : false, + isset($info->title) && is_string($info->title) ? $info->title : '', new DateTimeImmutable(isset($info->created_at) && is_string($info->created_at) ? $info->created_at : '@0'), isset($info->last_active_at) && is_string($info->last_active_at) ? new DateTimeImmutable($info->last_active_at) : null, - isset($info->roles) && is_array($info->roles) ? $info->roles : [], // @phpstan-ignore-line - isset($info->title) && is_string($info->title) ? $info->title : '', - isset($info->super) && is_bool($info->super) ? $info->super : false, - isset($info->deleted) && is_bool($info->deleted) ? $info->deleted : false + isset($info->profile_url) && is_string($info->profile_url) ? $info->profile_url : '', + isset($info->avatar_urls) && is_array($info->avatar_urls) ? array_map(fn(mixed $item) => (is_object($item) ? V1UserAvatar::decode($item) : V1UserAvatar::empty()), $info->avatar_urls) : [], + isset($info->is_deleted) && is_bool($info->is_deleted) ? $info->is_deleted : false ); } }