| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class StringSerializeConverter implements IEnumSetConverter |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $enumClass; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param string $enumClass |
||
| 20 | */ |
||
| 21 | 9 | public function __construct($enumClass) |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param string $serialized |
||
| 31 | * @return ImmutableSet |
||
| 32 | */ |
||
| 33 | public function convertToEnumSet($serialized): ISet |
||
| 34 | { |
||
| 35 | 4 | $serialized = (string) $serialized; |
|
| 36 | 4 | $stringList = unserialize($serialized); |
|
| 37 | |||
| 38 | 4 | $set = []; |
|
| 39 | 4 | foreach ($stringList as $value) { |
|
| 40 | 3 | $set[] = call_user_func([$this->enumClass, 'instance'], $value); |
|
| 41 | } |
||
| 42 | 4 | return new ImmutableSet($this->enumClass, $set); |
|
| 43 | } |
||
| 44 | |||
| 45 | public function convertFromEnumSet(ISet $enumSet): string |
||
| 52 | } |
||
| 53 | } |
||
| 54 |