| @@ 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 | } |
|
| @@ 66-72 (lines=7) @@ | ||
| 63 | { |
|
| 64 | $class = $type->getName(); |
|
| 65 | ||
| 66 | if (!$data instanceof $class) { |
|
| 67 | throw new \InvalidArgumentException(sprintf( |
|
| 68 | 'Expected a "%s", got "%s".', |
|
| 69 | $class, |
|
| 70 | is_object($data) ? get_class($data) : gettype($data) |
|
| 71 | )); |
|
| 72 | } |
|
| 73 | ||
| 74 | $result = $data->format($format = $type->getOption('format', $this->format)); |
|
| 75 | ||