-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
479dbe9
commit 476f6f7
Showing
4 changed files
with
44 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storyblok\Mapi\Data\Enum; | ||
|
||
enum Region: string | ||
{ | ||
case EU = 'EU'; | ||
case US = 'US'; | ||
case AP = 'AP'; | ||
case CA = 'CA'; | ||
case CN = 'CN'; | ||
|
||
/** | ||
* Get all region values as an array. | ||
* | ||
* @return array<string> | ||
*/ | ||
public static function values(): array | ||
{ | ||
return array_column(self::cases(), 'value'); | ||
} | ||
|
||
/** | ||
* Check if a value is a valid region. | ||
* | ||
* @param string $value the code of region to be validated | ||
* @return bool true if the region is one of the valid region (Upper case) | ||
*/ | ||
public static function isValid(string $value): bool | ||
{ | ||
return in_array($value, self::values(), true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters