Determine loader from source

@param object|string $source
@return LoaderInterface
@throws NoLoaderException
764166
protected function determineLoader($source): LoaderInterface
    {
        expect_type($source, ['object', 'string']);

        return is_object($source)
            ? $this->determineLoaderFromClass($source)
            : $this->determineLoaderFromPath($source);
    }
1077602
private function loadExternalRef($reference)
    {
        list($prefix, $path) = parse_external_ref($reference);
        return $this->loaderManager->getLoader($prefix)->load($path);
    }
562388
private function coalesceSources($source = null)
    {
        if (isset($source)) {
            return $source;
        } elseif (isset($this->source)) {
            return $this->source;
        }

        return $_SERVER;
    }
1048538
public function setLoader($name, LoaderInterface $loader)
    {
        // If name is int or null, get name from Loader object.
        $name = (is_numeric($name) || !$name) ? $loader->getName() : $name;

        $this->loaders[$name] = $loader;

        return $this;
    }
1087674
public function read($source) {
		$source = $this->escapePath($source);
		// since returned stream is closed by the caller we need to create a new instance
		// since we can't re-use the same file descriptor over multiple calls
		$connection = $this->getConnection();

		$connection->write('get ' . $source . ' ' . $this->system->getFD(5));
		$connection->write('exit');
		$fh = $connection->getFileOutputStream();
		stream_context_set_option($fh, 'file', 'connection', $connection);
		return $fh;
	}
336781
public function read($source) {
		$url = $this->buildUrl($source);
		$handle = $this->getState()->open($url, 'r');
		return NativeReadStream::wrap($this->getState(), $handle, 'r', $url);
	}
1367595
private function buildLoader($loader)
    {
        if ($loader instanceof TemplateLoaderInterface || is_callable($loader)) {
            return $loader;
        }

        if (is_string($loader) && is_subclass_of($loader, TemplateLoaderInterface::class, true)) {
            return function () use ($loader) {
                return new $loader();
            };
        }
    }
1314244
public static function fromArray( $source )
	{
		try
		{
			$classname = get_called_class();

			if ( ! class_exists( $classname ) )
			{
				\XBRL_Log::getInstance()->err( "The class '$classname' does not exist" );
				return null;
			}

			$instance = new $classname();

			if ( ! $instance instanceof Resource )
			{
				\XBRL_Log::getInstance()->err( "The class instance being created MUST inherit from 'XBRL\\Formulas\\Resources\\Resources'" );
				return null;
			}

			$has = get_object_vars( $instance );
			foreach ( $has as $name => $oldValue )
			{
	        	if ( ! isset( $source[ $name ] ) ) continue;
	        	$instance->$name = $source[ $name ];
			}

			return $instance;
		}
		catch( \Exception $ex )
		{
			return null;
		}
	}
1073005
public function setSource($source)
    {
        if ($source instanceof ListSource) {
            $this->source = $source;
        }
        
        if ($source instanceof SS_List) {
            $this->source = ListWrapper::create($source);
        }
        
        return $this->owner;
    }
418415
public static function make($source)
    {
        $engines  = config('datatables.engines');
        $builders = config('datatables.builders');

        $args = func_get_args();
        foreach ($builders as $class => $engine) {
            if ($source instanceof $class) {
                return call_user_func_array([$engines[$engine], 'create'], $args);
            }
        }

        foreach ($engines as $engine => $class) {
            if (call_user_func_array([$engines[$engine], 'canCreate'], $args)) {
                return call_user_func_array([$engines[$engine], 'create'], $args);
            }
        }

        throw new \Exception('No available engine for ' . get_class($source));
    }
1108889
protected function load($source)
    {
        $reader = new FileReader($source);

        $dictionary = new MimeTypeDictionary($reader);

        foreach ($dictionary as $entry) {
            $this->dict += array_fill_keys(
                $entry->fileExtensions,
                $entry->mimeType
            );
        }
    }
1044999
public function readSource($source)
    {
        $document = new \DOMDocument();
        $errorToExceptionContext = new ErrorToExceptionContext(E_WARNING, function () use ($source, $document) {
            $document->loadXML($source);
        });
        $errorToExceptionContext->invoke();

        return $this->readDocument($document);
    }
799742
public function loadString($source, $url = null)
    {
        parent::loadString($source);

        //Let mustache load the source by proxiing through the load() method.
        $this->_mustache_template = $this->_mustache->loadTemplate($source);

        //Push the template on the stack
        array_push($this->_stack, $url);

        return $this;
    }
1120697
public function setSource($source)
    {
        $sourceAttribute = $this->sourceAttribute;
        return (is_string($sourceAttribute) && !empty($sourceAttribute)) ? $this->$sourceAttribute = $source : null;
    }
1080593
public function setLoader(LoaderInterface $loader)
    {
        $this->loader = $loader;

        if ($this->collector && ($loader instanceof ResourceAwareInterface)) {
            $loader->setResourceCollector($this->collector);
        }

        if ($loader instanceof WiseAwareInterface) {
            $loader->setWise($this);
        }

        if ($loader instanceof DelegatingLoader) {
            $resolver = $loader->getResolver();

            if ($this->collector && ($resolver instanceof ResourceAwareInterface)) {
                $resolver->setResourceCollector($this->collector);
            }

            if ($resolver instanceof WiseAwareInterface) {
                $resolver->setWise($this);
            }

        }
    }
904833
public static function setSource($source = null)
    {
        if (! is_resource($source) && ! is_null($source)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid source provided; must be a null or an resource, "%s" given.',
                is_object($source) ? get_class($source) : gettype($source)
            ));
        }
        static::$source = $source;
    }
1351801
public final function removePrefix(string $prefix): LoaderInterface
    {
        $parsedPrefix = $this->parsePrefix($prefix);
        if (array_key_exists($parsedPrefix, $this->prefix)) {
            unset($this->prefix[$parsedPrefix]);
        }
        return $this;
    }