Ejemplo 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 StdString) {
         return $value;
     }
     try {
         $string = StdString::create($value);
     } catch (Exception $exception) {
         throw ConversionException::conversionFailed($value, static::TYPE_NAME);
     }
     return $string;
 }
Ejemplo n.º 2
0
 /**
  * Created StdString instance
  *
  * @param mixed $value The string value
  *
  * @return StdString
  *
  * @throws DomainException When the value is not valid
  */
 function stdString($value) : StdString
 {
     if (!Validate::isStringCastable($value)) {
         $message = sprintf('Invalid string value: %s', VarPrinter::toString($value));
         throw new DomainException($message);
     }
     if ($value instanceof StdString) {
         return $value;
     }
     /** @var StdString $string */
     $string = StdString::create((string) $value);
     return $string;
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \AssertionError
  */
 public function test_that_compare_to_throws_exception_for_invalid_argument()
 {
     $string = StdString::create('hello');
     $string->compareTo('hello');
 }