Skip to content

Commit

Permalink
Add enum name method
Browse files Browse the repository at this point in the history
  • Loading branch information
shimonhaga committed Feb 21, 2023
1 parent 1b99309 commit 3ec8a40
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Constants/DeliveryChargeFreeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => '請求しない',
};
}
}
10 changes: 10 additions & 0 deletions src/Constants/DeliveryChargeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => '商品重量を基準に設定',
};
}
}
11 changes: 11 additions & 0 deletions src/Constants/DeliveryMethodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => '日本郵便',
};
}
}
8 changes: 8 additions & 0 deletions src/Constants/DisplayState.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ enum DisplayState: string
{
case SHOWING = 'showing';
case HIDDEN = 'hidden';

public function name(): string
{
return match ($this) {
self::SHOWING => '表示する',
self::HIDDEN => '表示しない',
};
}
}
2 changes: 1 addition & 1 deletion src/Constants/PaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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後払い
Expand Down

0 comments on commit 3ec8a40

Please sign in to comment.