PHP8.1が出たのでmyclabs/php-enumから列挙型(Enum)に置き換えが出来るか試してみた
declare(strict_types=1); use MyCLabs\Enum\Enum; class Cardsuit extends Enum { public const CLUBS = 1; public const DIAMONDS = 2; public const HEARTS = 3; public const SPADES = 4; public function label(): string { return match($this->value) { self::CLUBS => 'クラブ', self::DIAMONDS => 'ダイヤモン…
もっと詳しく