protected function parseTransformer($transformer, Model $model)
    {
        if ($transformer instanceof Transformer) {
            $relations = $transformer->allRelationsAllowed() ? $this->resolveRelations($model) : $transformer->getRelations();
            $transformer = $transformer->setRelations($relations);

        } elseif (! is_callable($transformer)) {
            throw new InvalidTransformerException($model);
        }

        return $transformer;
    }