No Compromises

How much logic is too much logic in a PHP enum


Listen Later

Have you ever added a method to an enum and then wondered if you just turned it into something it was never meant to be?

In the latest episode of the No Compromises podcast, we discuss where to draw the line when adding methods and logic to PHP enums.

We trace the evolution from magic strings to constants to interfaces, and explain why enums were the missing piece PHP needed all along.

We also cover when label methods and data structure helpers belong on an enum, why Eloquent queries cross a line, and how to avoid turning a simple enum into a bloated helper class.

  • (00:00) - Why magic strings and constants fall short
  • (01:43) - How PHP enums replaced interface constants
  • (02:26) - What methods belong on an enum
  • (06:58) - The rule for keeping enum methods focused
  • (10:44) - Silly bit

  • Join developers who think carefully about clean code decisions in the No Compromises community.
    ...more
    View all episodesView all episodes
    Download on the App Store

    No CompromisesBy Joel Clermont and Aaron Saray

    • 4.9
    • 4.9
    • 4.9
    • 4.9
    • 4.9

    4.9

    8 ratings


    More shows like No Compromises

    View all
    The Laravel Podcast by Matt Stauffer

    The Laravel Podcast

    57 Listeners

    Startups For the Rest of Us by Rob Walling

    Startups For the Rest of Us

    701 Listeners

    Darknet Diaries by Jack Rhysider

    Darknet Diaries

    8,059 Listeners

    Notes On Work - by Caleb Porzio by Caleb Porzio

    Notes On Work - by Caleb Porzio

    18 Listeners

    The Stack Overflow Podcast by The Stack Overflow Podcast

    The Stack Overflow Podcast

    64 Listeners

    The Bootstrapped Founder by Arvid Kahl

    The Bootstrapped Founder

    34 Listeners

    All-In with Chamath, Jason, Sacks & Friedberg by All-In Podcast, LLC

    All-In with Chamath, Jason, Sacks & Friedberg

    10,208 Listeners

    Hard Fork by The New York Times

    Hard Fork

    5,549 Listeners

    Mostly Technical by Ian Landsman and Aaron Francis

    Mostly Technical

    27 Listeners