Programming Language PHP

Namespace Plank\Mediable\Exceptions\MediaUpload

Class ConfigurationException

Method/Function unrecognizedSource

Total Examples 1

1 code examples of PHP Plank\Mediable\Exceptions\MediaUpload\ConfigurationException::unrecognizedSource extracted from open source projects

Was this example useful?
0
                                                    /**
     * Create a Source Adapter for the provided source.
     * @param  object|string|resource $source
     * @throws ConfigurationException If the provided source does not match any of the mapped classes or patterns
     */
    public function create($source): SourceAdapterInterface
    {
        $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);
    }
                                            
ConfigurationException's Other Methods