PHP Enums tryFrom Method
I was recently working on a project where I was receiving data from an API that had a payment_type. I converted the payment_type into the enum below:
enum PaymentType: string
{
case CREDIT_CARD = 'credit_card';
case APPLE_PAY = 'apple_pay';
...
seankegel.com2 min read