Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing methods changeXXX to some properties to have a more consistent API accross properties. #342

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Databases/Properties/StatusOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public function toArray(): array

return $option;
}

public function changeName(string $name): self
{
return new self($this->id, $name, $this->color);
}
}
5 changes: 5 additions & 0 deletions src/Pages/Properties/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function metadata(): PropertyMetadata
return $this->metadata;
}

public function changeDate(CommonDate $date): self
{
return new self($this->metadata, $date);
}

public function changeStart(DateTimeImmutable $start): self
{
return new self($this->metadata, $this->date?->changeStart($start));
Expand Down
8 changes: 8 additions & 0 deletions src/Pages/Properties/MultiSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ public function removeOption(string $optionId): self
array_filter($this->options, fn (SelectOption $o) => $o->id !== $optionId),
);
}

public function changeOptions(array $options): self
{
return new self(
$this->metadata,
array_filter($options, fn ($o) => $o instanceof SelectOption),
);
}
ren0v marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions src/Pages/Properties/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ public function metadata(): PropertyMetadata
{
return $this->metadata;
}

public function changeOption(StatusOption $option): self
{
return new self($this->metadata, $option);
}
}
Loading