- Output for 8.1.28 - 8.1.33, 8.2.3 - 8.2.29, 8.3.5 - 8.3.25, 8.4.1 - 8.4.12
- enum(PaymentMethods::PAYPAL)
<?php
enum PaymentMethods : string
{
case PAYPAL = 'pay with paypal';
case STRIPE = 'pay with stripe';
public static function fromName(string $method): PaymentMethods
{
foreach(PaymentMethods::cases() as $case) {
if ($case->name === $method) {
return $case;
}
}
return null;
}
}
$method= "PAYPAL";
var_dump(PaymentMethods::fromName($method));