src/SourceAdapters/SourceAdapterFactory.php
public function create($source)
    {
        $adapter = null;

        if ($source instanceof SourceAdapterInterface) {
            return $source;
        } elseif (is_object($source)) {
            $adapter = $this->adaptClass($source);
        } elseif (is_resource($source)) {
            $adapter = StreamResourceAdapter::class;
        } elseif (is_string($source)) {
            $adapter = $this->adaptString($source);
        }

        if ($adapter) {
            return new $adapter($source);
        }

        throw ConfigurationException::unrecognizedSource($source);
    }
public function create($source)
    {
        $adapter = null;

        if ($source instanceof SourceAdapterInterface) {
            return $source;
        } elseif (is_object($source)) {
            $adapter = $this->adaptClass($source);
        } elseif (is_resource($source)) {
            $adapter = StreamResourceAdapter::class;
        } elseif (is_string($source)) {
            $adapter = $this->adaptString($source);
        }

        if ($adapter) {
            return new $adapter($source);
        }

        throw ConfigurationException::unrecognizedSource($source);
    }
public function create ( $ source ) { $ adapter = null ; if ( $ source instanceof SourceAdapterInterface ) { return $ source ; } elseif ( is_object ( $ source ) ) { $ adapter = $ this -> adaptClass ( $ source ) ; } elseif ( is_resource ( $ source ) ) { $ adapter = StreamResourceAdapter :: class ; } elseif ( is_string ( $ source ) ) { $ adapter = $ this -> adaptString ( $ source ) ; } if ( $ adapter ) { return new $ adapter ( $ source ) ; } throw ConfigurationException :: unrecognizedSource ( $ source ) ; }
Create a Source Adapter for the provided source.
@param  object|string $source
@return \Plank\Mediable\SourceAdapters\SourceAdapterInterface
@throws \Plank\Mediable\Exceptions\MediaUpload\ConfigurationException If the provided source does not match any of the mapped classes or patterns
Create a Source Adapter for the provided source .