protected function deriveReceivedClass(callable $transformer)
    {
        if (is_array($transformer)) {
            $r = new \ReflectionMethod($transformer[0], $transformer[1]);
        } elseif (is_object($transformer) && !$transformer instanceof \Closure) {
            $r = new \ReflectionObject($transformer);
            $r = $r->getMethod('__invoke');
        } else {
            $r = new \ReflectionFunction($transformer);
        }

        $parameters = $r->getParameters();
        if (count($parameters) != 1) {
            throw new InvalidTransformerException('A transformer must have one parameter and it must be typed to the input class type.');
        }

        $class = $parameters[0]->getClass();

        if (!$class) {
            throw new InvalidTransformerException();
        }

        return $class->name;
    }