1 | <?php |
||
2 | |||
3 | namespace Stadem\VivaPayments\Enums; |
||
4 | |||
5 | enum PaymentMethods: int |
||
6 | { |
||
7 | case CreditCard = 0; |
||
8 | case Cash = 3; |
||
9 | case eBanking = 4; |
||
10 | case VivaWallet = 8; |
||
11 | case iDEAL = 10; |
||
12 | case P24 = 11; |
||
13 | case BLIK = 12; |
||
14 | case PayU = 13; |
||
15 | case giropay = 15; |
||
16 | case Sofort = 16; |
||
17 | case EPS = 17; |
||
18 | case WeChatPay = 18; |
||
19 | case BitPay = 19; |
||
20 | case PayPal = 23; |
||
21 | case Trustly = 24; |
||
22 | case Klarna = 26; |
||
23 | case BancontactQR = 27; |
||
24 | case Payconiq = 28; |
||
25 | case IRIS = 29; |
||
26 | case PayByBank = 30; |
||
27 | case MBWAY = 31; |
||
28 | case MULTIBANCO = 32; |
||
29 | case TbiBank = 34; |
||
30 | case PayOnDelivery = 35; |
||
31 | case MobilePayOnline = 36; |
||
32 | case BANCOMATPay = 37; |
||
33 | case Bluecode = 41; |
||
34 | case Satispay = 43; |
||
35 | case Swish = 221; |
||
36 | |||
37 | /** |
||
38 | * Return value as string |
||
39 | * Enums\PaymentMethods::fromName('Dias'); |
||
40 | */ |
||
41 | |||
42 | |||
43 | public static function fromName(string $name): int |
||
44 | { |
||
45 | foreach (self::cases() as $status) { |
||
46 | if( $name === $status->name ){ |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
47 | return $status->value; |
||
48 | } |
||
49 | } |
||
50 | throw new \ValueError("$name is not a valid backing value for enum " . self::class ); |
||
51 | } |
||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * Return value as string |
||
57 | * Enums\PaymentMethods::fromValue(15); |
||
58 | */ |
||
59 | |||
60 | public static function fromValue(int $value): string |
||
61 | { |
||
62 | foreach (self::cases() as $status) { |
||
63 | if( $value === $status->value ){ |
||
64 | return $status->name; |
||
0 ignored issues
–
show
|
|||
65 | } |
||
66 | } |
||
67 | throw new \ValueError("$value is not a valid backing value for enum " . self::class ); |
||
68 | } |
||
69 | |||
70 | |||
71 | |||
72 | } |