src/Set/Converter/StringSerializeConverter.php 1 location
|
@@ 33-43 (lines=11) @@
|
| 30 |
|
* @param string $serialized |
| 31 |
|
* @return ImmutableSet |
| 32 |
|
*/ |
| 33 |
|
public function convertToEnumSet($serialized) |
| 34 |
|
{ |
| 35 |
|
$serialized = (string) $serialized; |
| 36 |
|
$stringList = unserialize($serialized); |
| 37 |
|
|
| 38 |
|
$set = []; |
| 39 |
|
foreach ($stringList as $value) { |
| 40 |
|
$set[] = call_user_func([$this->enumClass, 'instance'], $value); |
| 41 |
|
} |
| 42 |
|
return new ImmutableSet($this->enumClass, $set); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* @param ISet $enumSet |
src/Set/Converter/BitMaskConverter.php 1 location
|
@@ 36-47 (lines=12) @@
|
| 33 |
|
* @param int $values |
| 34 |
|
* @return ISet |
| 35 |
|
*/ |
| 36 |
|
public function convertToEnumSet($values) |
| 37 |
|
{ |
| 38 |
|
$bitValue = (int) $values; |
| 39 |
|
|
| 40 |
|
$set = []; |
| 41 |
|
foreach ($this->mapping as $value => $bit) { |
| 42 |
|
if ($bitValue & $bit) { |
| 43 |
|
$set[] = call_user_func([$this->enumClass, 'instance'], $value); |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
return new ImmutableSet($this->enumClass, $set); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
/** |
| 50 |
|
* @param ISet $enumSet |