expected() public static method

public static expected ( string $expectedType, $receivedValue ) : InvalidArgumentException
$expectedType string
$receivedValue
return InvalidArgumentException
Example #1
0
 /**
  * @param $serializedValue
  *
  * @return float
  * @throws InvalidArgumentException
  */
 public function deserialize($serializedValue)
 {
     if (null === $serializedValue && $this->isNullable()) {
         return $this->default === null ? null : $this->default;
     }
     if (!is_string($serializedValue)) {
         throw InvalidArgumentException::expected('string', $serializedValue);
     }
     return (double) $serializedValue;
 }
Example #2
0
 /**
  * @param string $serializedValue
  *
  * @return null|Association
  * @throws InvalidArgumentException
  */
 public function deserialize($serializedValue)
 {
     if (null === $serializedValue && $this->isNullable()) {
         return null;
     }
     if (!is_string($serializedValue)) {
         throw InvalidArgumentException::expected('string', $serializedValue);
     }
     return new Association($this->schema, $this->typeSchema, ['id' => $serializedValue]);
 }