Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat. EnumArtist, feat. better String artist, feat. PHP 8.1 required now
- Loading branch information
Showing
5 changed files
with
100 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
= V 0.9.3 = | ||
|
||
- Requires PHP 8.1 now | ||
- Enum Artist | ||
- Various minor improvements | ||
|
||
= V 0.8.2 = | ||
|
||
- Remove deprecations | ||
|
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,47 @@ | ||
<?php | ||
|
||
namespace CisTools; | ||
|
||
use BackedEnum; | ||
use InvalidArgumentException; | ||
|
||
class EnumArtist | ||
{ | ||
|
||
/** | ||
* Get all values from a backend enum. | ||
* @param array $enums | ||
* @return array | ||
*/ | ||
public static function getBackedEnumNames(array $enums): array | ||
{ | ||
$result = []; | ||
foreach($enums as $enum) { | ||
if(!($enum instanceof BackedEnum)) { | ||
throw new InvalidArgumentException("You have to pass an array of backed enums."); | ||
} | ||
$result[] = $enum->name; | ||
} | ||
return $result; | ||
} | ||
|
||
|
||
/** | ||
* Get all values from a backend enum. | ||
* | ||
* @param array $enums | ||
* @return array | ||
*/ | ||
public static function getBackedEnumValues(array $enums): array | ||
{ | ||
$result = []; | ||
foreach($enums as $enum) { | ||
if(!($enum instanceof BackedEnum)) { | ||
throw new InvalidArgumentException("You have to pass an array of backed enums."); | ||
} | ||
$result[] = $enum->value; | ||
} | ||
return $result; | ||
} | ||
|
||
} |
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