Skip to content

Commit 50b3b65

Browse files
committed
EnumSet: added getEnumerators(), getNames() and getValues()
1 parent 6af8018 commit 50b3b65

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/EnumSet.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,45 @@ public function isSuperset(EnumSet $other)
240240
return ($thisBitset | $other->getBinaryBitsetLe()) === $thisBitset;
241241
}
242242

243+
/**
244+
* Get values of the defined enumerators as array
245+
* @return null[]|bool[]|int[]|float[]|string[]
246+
*/
247+
public function getValues()
248+
{
249+
$values = array();
250+
foreach ($this as $enumerator) {
251+
$values[] = $enumerator->getValue();
252+
}
253+
return $values;
254+
}
255+
256+
/**
257+
* Get names of the defined enumerators as array
258+
* @return string[]
259+
*/
260+
public function getNames()
261+
{
262+
$names = array();
263+
foreach ($this as $enumerator) {
264+
$names[] = $enumerator->getName();
265+
}
266+
return $names;
267+
}
268+
269+
/**
270+
* Get the defined enumerators as array
271+
* @return Enum[]
272+
*/
273+
public function getEnumerators()
274+
{
275+
$enumerators = array();
276+
foreach ($this as $enumerator) {
277+
$enumerators[] = $enumerator->getName();
278+
}
279+
return $enumerators;
280+
}
281+
243282
/**
244283
* Get binary bitset in little-endian order
245284
*

0 commit comments

Comments
 (0)