Skip to content

Add is helpers to enums #2

@NeroAzure

Description

@NeroAzure

This helpers would simplify checks under special conditions.

Let's say the we have an enum PublishingState with the values DRAFT, PUBLISHING, PUBLISHED.

is()

if ($post->state->is(PublishingState::DRAFT())) {
  ...
}

is<EnumValue>

and in extension a dynamic method is<EnumValue>:

if ($post->state->isDraft()) {
  ...
}

The benefit of this especially would be an enhanced readability.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions