Inheritance: extends InvalidArgumentException
Example #1
0
 /**
  * @param $value
  *
  * @return string
  * @throws InvalidValueException
  */
 public function serialize($value) : string
 {
     if (!is_numeric($value)) {
         throw InvalidValueException::valueDoesNotMatchType($this, $value);
     }
     return (string) (double) $value;
 }
Example #2
0
 /**
  * @param $value
  *
  * @return string
  * @throws InvalidValueException
  */
 public function serialize($value) : string
 {
     if (!$value instanceof Metadata) {
         throw InvalidValueException::valueDoesNotMatchType($this, $value);
     }
     return (string) $value->id();
 }
Example #3
0
 /**
  * @param $value
  *
  * @return string
  * @throws InvalidValueException
  */
 public function serialize($value) : string
 {
     if (null !== $value && !is_array($value)) {
         throw InvalidValueException::valueDoesNotMatchType($this, $value);
     }
     return json_encode($value);
 }
Example #4
0
 /**
  * @param $value
  * @return string
  * @throws InvalidValueException
  */
 public function serialize($value) : string
 {
     if (!is_string($value)) {
         throw InvalidValueException::valueDoesNotMatchType($this, $value);
     }
     return $value;
 }
Example #5
0
 /**
  * @param $value
  *
  * @return string
  * @throws InvalidValueException
  */
 public function serialize($value) : string
 {
     if (!$value instanceof \DateTimeInterface) {
         throw InvalidValueException::valueDoesNotMatchType($this, $value);
     }
     return (string) $value->format($this->format);
 }