From 3ec8a40bf8b5501e94947ffa54d4051cebeb84d7 Mon Sep 17 00:00:00 2001 From: shimonhaga Date: Wed, 22 Feb 2023 06:14:38 +0900 Subject: [PATCH] Add enum name method --- src/Constants/DeliveryChargeFreeType.php | 11 ++++++++++- src/Constants/DeliveryChargeType.php | 10 ++++++++++ src/Constants/DeliveryMethodType.php | 11 +++++++++++ src/Constants/DisplayState.php | 8 ++++++++ src/Constants/PaymentType.php | 2 +- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Constants/DeliveryChargeFreeType.php b/src/Constants/DeliveryChargeFreeType.php index f6a0d2c..e0d4166 100644 --- a/src/Constants/DeliveryChargeFreeType.php +++ b/src/Constants/DeliveryChargeFreeType.php @@ -5,6 +5,15 @@ enum DeliveryChargeFreeType: string { case NOT_FREE = 'not_free'; // 有料 - case FREE = 'free'; // 無料 case FREE_TO_LIMIT = 'free_to_limit'; // 注文金額が一定以上の場合は無料 + case FREE = 'free'; // 無料 + + public function name(): string + { + return match ($this) { + self::NOT_FREE => '請求する', + self::FREE_TO_LIMIT => '請求する(無料となる上限金額あり)', + self::FREE => '請求しない', + }; + } } diff --git a/src/Constants/DeliveryChargeType.php b/src/Constants/DeliveryChargeType.php index 0d7933e..67e6cba 100644 --- a/src/Constants/DeliveryChargeType.php +++ b/src/Constants/DeliveryChargeType.php @@ -8,4 +8,14 @@ enum DeliveryChargeType: string case BY_PRICE = 'by_price'; // 注文金額によって決定 case BY_AREA = 'by_area'; // 配送先都道府県によって決定 case BY_WEIGHT = 'by_weight'; // 商品重量によって決定 + + public function name(): string + { + return match ($this) { + self::FIXED => '全国一律', + self::BY_PRICE => '注文金額にて設定', + self::BY_AREA => '送付先にて設定', + self::BY_WEIGHT => '商品重量を基準に設定', + }; + } } diff --git a/src/Constants/DeliveryMethodType.php b/src/Constants/DeliveryMethodType.php index 2d31eaf..77430d5 100644 --- a/src/Constants/DeliveryMethodType.php +++ b/src/Constants/DeliveryMethodType.php @@ -9,4 +9,15 @@ enum DeliveryMethodType: string case YAMATO_PICKUP = 'yamato_pickup'; // ヤマト自宅外受け取り case SAGAWA = 'sagawa'; // 佐川急便 case JP = 'jp'; // 日本郵便 + + public function name(): string + { + return match ($this) { + self::OTHER => 'その他', + self::YAMATO => 'クロネコヤマト', + self::YAMATO_PICKUP => 'クロネコヤマト (自宅外受け取り)', + self::SAGAWA => '佐川急便', + self::JP => '日本郵便', + }; + } } diff --git a/src/Constants/DisplayState.php b/src/Constants/DisplayState.php index 4f4e96a..73be98c 100644 --- a/src/Constants/DisplayState.php +++ b/src/Constants/DisplayState.php @@ -6,4 +6,12 @@ enum DisplayState: string { case SHOWING = 'showing'; case HIDDEN = 'hidden'; + + public function name(): string + { + return match ($this) { + self::SHOWING => '表示する', + self::HIDDEN => '表示しない', + }; + } } diff --git a/src/Constants/PaymentType.php b/src/Constants/PaymentType.php index dba2bd6..ce03c5a 100644 --- a/src/Constants/PaymentType.php +++ b/src/Constants/PaymentType.php @@ -6,7 +6,7 @@ enum PaymentType: int { case COD = 0; // 商品代引 case BANK_TRANSFER = 1; // 銀行振込 - case POSTAL_TRANSFER = 2; // ちゅうちょ振替 + case POSTAL_TRANSFER = 2; // ゆうちょ振替 case CREDIT_ZEUS = 3; // クレジット(ZEUS) case KURONEKO_PAYMENT = 4; // クロネコ@ペイメント case COD_NP = 5; // NP後払い