protected function rootInstance($root)
    {
        if (is_object($root)) {
            return $root;
        }

        if (!is_string($root)) {
            throw new InvalidArgumentException('If you pass a path to type() it has to be array, object or a class not '.gettype($root));
        }

        if (!class_exists($root)) {
            throw new InvalidArgumentException("The passed class '$root' does not exist");
        }

        return new $root();
    }