Esempio n. 1
0
 /**
  * Converts a value from its database representation to its PHP representation
  *
  * @param mixed            $value    The value to convert
  * @param AbstractPlatform $platform The currently used database platform
  *
  * @return mixed
  *
  * @throws ConversionException When the conversion fails
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return null;
     }
     if ($value instanceof Uuid) {
         return $value;
     }
     try {
         $uuid = Uuid::parse($value);
     } catch (Exception $exception) {
         throw ConversionException::conversionFailed($value, static::TYPE_NAME);
     }
     return $uuid;
 }
Esempio n. 2
0
 /**
  * Creates instance from a string representation
  *
  * @param string $value The UUID string
  *
  * @return UniqueId
  *
  * @throws DomainException When the UUID is not valid
  */
 public static function fromString(string $value)
 {
     return new static(Uuid::parse($value));
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public static function fromString($id)
 {
     assert(Test::isString($id), sprintf('%s expects $id to be a string', __METHOD__));
     return new static(Uuid::parse($id));
 }
Esempio n. 4
0
 /**
  * @expectedException Novuso\System\Exception\DomainException
  */
 public function test_that_parse_throws_exception_with_invalid_string()
 {
     Uuid::parse('71967621-a924-4c58-a8f2e0-73967744e0');
 }