repository->find($data['id']); if (null === $person) { throw new UnexpectedValueException("The person with id \"{$data['id']}\" does ".'not exists'); } return $person; } throw new LogicException(); } public function supportsDenormalization($data, string $type, ?string $format = null) { return is_array($data) && Person::class === $type && 'person' === ($data['type'] ?? null) && isset($data['id']); } }