|
@@ 60-62 (lines=3) @@
|
| 57 |
|
throw new UnableToConvertException(sprintf('Unable to convert: Value %s is not a scalar value.', print_r($value, true))); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
if (!isset($this->enumMap[$value])) { |
| 61 |
|
throw new UnableToConvertException(sprintf('Unable to convert: Value %s not found in possible options: [%s]', $value, implode(', ', array_keys($this->enumMap)))); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
return $this->enumMap[$value]; |
| 65 |
|
} |
|
@@ 74-83 (lines=10) @@
|
| 71 |
|
*/ |
| 72 |
|
public function fromEnum(Enum $enum) |
| 73 |
|
{ |
| 74 |
|
if (!isset($this->scalarMap[(string) $enum])) { |
| 75 |
|
throw new UnableToConvertException( |
| 76 |
|
sprintf( |
| 77 |
|
'Unable to convert: Enum %s::%s() not found in possible options: [%s]', |
| 78 |
|
get_class($enum), |
| 79 |
|
(string) $enum, |
| 80 |
|
implode(', ', array_keys($this->enumMap)) |
| 81 |
|
) |
| 82 |
|
); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
return $this->scalarMap[(string) $enum]; |
| 86 |
|
} |