---
title: "Discussion on \"PHP use an enum for Filters\" | Hashnode"
description: "Discussion on \"PHP use an enum for Filters\". I have a class that allows filtering based on an option, I need a way to accept options and also reject invalid options.\nIn the past, I would reach for a switch statement, or more recently a match statement. But an enum is better suited for this task..."
url: "https://hashnode.com/posts/php-use-an-enum-for-filters/6634c29c14fedd0d453fa624"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [PHP use an enum for Filters](https://dcblog.dev/php-use-an-enum-for-filters?utm_source=hashnode&utm_medium=feed)

I have a class that allows filtering based on an option, I need a way to accept options and also reject invalid options. In the past, I would reach for a switch statement, or more recently a match statement. But an enum is better suited for this task...

May 3, 2024 · 2 min read · dcblog.dev  
Read the article

-   [#filter](https://hashnode.com/tag/filter)
-   [#enum](https://hashnode.com/tag/enum)
-   [#testing](https://hashnode.com/tag/testing)
-   [#pestphp](https://hashnode.com/tag/pestphp)

## Written by

[David Carr](https://hashnode.com/@dcblogdev)

@dcblogdev · United Kingdom

  
[View profile](https://hashnode.com/@dcblogdev)

Web developer

Blogger at http://dcblog.dev.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
