Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyen Van Nguyen <nguyennv1981@gmail.com>
  • Loading branch information
nguyennv committed Apr 23, 2024
1 parent c5682d3 commit 59ece56
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ parameters:
- src/Account/AccountApi.php
- src/Admin/AdminApi.php
- src/Mail/MailApi.php
ignoreErrors:
- '~has invalid type Doctrine\\Common\\Annotations\\Reader~'
paths:
- src
8 changes: 6 additions & 2 deletions src/Admin/Struct/ReindexMailboxInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ public function getTypes(): ?string
*/
public function setTypes(string $types): self
{
$types = array_map(static fn ($type) => trim($type), explode(',', $types));
$types = array_filter($types, static fn ($type) => ReindexType::tryFrom($type));
$types = array_filter(
array_map(
static fn ($type) => trim($type), explode(',', $types)
),
static fn ($type) => ReindexType::tryFrom($type) !== null
);
$this->types = implode(',', array_unique($types));
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Struct/WaitSetAddSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function setInterests(string $interests): self
{
$types = array_filter(
explode(',', $interests),
static fn ($type) => InterestType::tryFrom($type)
static fn ($type) => InterestType::tryFrom($type) !== null
);
$this->interests = !empty($types) ? implode(',', array_unique($types)) : null;
return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Mail/Message/CreateWaitSetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public function getDefaultInterests(): string
public function setDefaultInterests(string $defaultInterests): self
{
$types = array_filter(
explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type)
explode(',', $defaultInterests),
static fn ($type) => InterestType::tryFrom($type) !== null
);
$this->defaultInterests = implode(',', array_unique($types));
return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Mail/Message/CreateWaitSetResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public function getDefaultInterests(): ?string
public function setDefaultInterests(string $defaultInterests): self
{
$types = array_filter(
explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type)
explode(',', $defaultInterests),
static fn ($type) => InterestType::tryFrom($type) !== null
);
$this->defaultInterests = implode(',', array_unique($types));
return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Mail/Message/WaitSetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ public function getDefaultInterests(): ?string
public function setDefaultInterests(string $defaultInterests): self
{
$types = array_filter(
explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type)
explode(',', $defaultInterests),
static fn ($type) => InterestType::tryFrom($type) !== null
);
$this->defaultInterests = implode(',', array_unique($types));
return $this;
Expand Down
6 changes: 4 additions & 2 deletions src/Mail/Struct/MailSearchParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ public function getAllowableTaskStatus(): ?string
public function setAllowableTaskStatus(string $allowableTaskStatus): self
{
$taskStatuses = array_filter(
explode(',', $allowableTaskStatus), static fn($status) => TaskStatus::tryFrom(trim($status))
explode(',', $allowableTaskStatus),
static fn($status) => TaskStatus::tryFrom(trim($status)) !== null
);
$this->allowableTaskStatus = implode(',', $taskStatuses);
return $this;
Expand Down Expand Up @@ -579,7 +580,8 @@ public function getSearchTypes(): ?string
public function setSearchTypes(string $searchTypes): self
{
$validTypes = array_filter(
explode(',', $searchTypes), static fn($type) => SearchType::tryFrom(trim($type))
explode(',', $searchTypes),
static fn($type) => SearchType::tryFrom(trim($type)) !== null
);
$this->searchTypes = implode(',', $validTypes);
return $this;
Expand Down

0 comments on commit 59ece56

Please sign in to comment.