| @@ 76-82 (lines=7) @@ | ||
| 73 | $type = $this->typeParser->parse($type); |
|
| 74 | } |
|
| 75 | ||
| 76 | if (!$type instanceof TypeMetadataInterface) { |
|
| 77 | throw new \InvalidArgumentException(sprintf( |
|
| 78 | 'The type must be a string or a "%s", got "%s".', |
|
| 79 | TypeMetadataInterface::class, |
|
| 80 | is_object($type) ? get_class($type) : gettype($type) |
|
| 81 | )); |
|
| 82 | } |
|
| 83 | ||
| 84 | return $this->navigate($data, Direction::DESERIALIZATION, $format, $context, $type); |
|
| 85 | } |
|
| @@ 49-55 (lines=7) @@ | ||
| 46 | { |
|
| 47 | $class = $type->getName(); |
|
| 48 | ||
| 49 | if (!$data instanceof $class) { |
|
| 50 | throw new \InvalidArgumentException(sprintf( |
|
| 51 | 'Expected a "%s", got "%s".', |
|
| 52 | $class, |
|
| 53 | is_object($data) ? get_class($data) : gettype($data) |
|
| 54 | )); |
|
| 55 | } |
|
| 56 | ||
| 57 | $result = $data->format($format = $type->getOption('format', $this->format)); |
|
| 58 | ||