src/Storage/File/StorableFileFactory.php
public function makeFromAny($data, $name = null, $mimeType = null)
    {
        // If the data is already a storable file, return it as-is.
        if ($data instanceof StorableFileInterface) {
            return $this->getReturnPreparedFile($data);
        }


        if (null === $name && is_a($data, \Symfony\Component\HttpFoundation\File\UploadedFile::class)) {
            /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $data */
            $name = $data->getClientOriginalName();
        }

        if ($data instanceof SplFileInfo) {
            return $this->makeFromFileInfo($data, $name, $mimeType);
        }


        // Fallback: expect raw or string data, and attempt to interpret it.
        if (is_string($data)) {
            $data = new RawContent($data);
        }

        if ( ! ($data instanceof RawContentInterface)) {
            throw new UnexpectedValueException('Could not interpret given data, string value expected');
        }

        return $this->interpretFromRawContent($data, $name, $mimeType);
    }
public function makeFromAny($data, $name = null, $mimeType = null)
    {
        // If the data is already a storable file, return it as-is.
        if ($data instanceof StorableFileInterface) {
            return $this->getReturnPreparedFile($data);
        }


        if (null === $name && is_a($data, \Symfony\Component\HttpFoundation\File\UploadedFile::class)) {
            /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $data */
            $name = $data->getClientOriginalName();
        }

        if ($data instanceof SplFileInfo) {
            return $this->makeFromFileInfo($data, $name, $mimeType);
        }


        // Fallback: expect raw or string data, and attempt to interpret it.
        if (is_string($data)) {
            $data = new RawContent($data);
        }

        if ( ! ($data instanceof RawContentInterface)) {
            throw new UnexpectedValueException('Could not interpret given data, string value expected');
        }

        return $this->interpretFromRawContent($data, $name, $mimeType);
    }
public function makeFromAny ( $ data , $ name = null , $ mimeType = null ) { // If the data is already a storable file, return it as-is. if ( $ data instanceof StorableFileInterface ) { return $ this -> getReturnPreparedFile ( $ data ) ; } if ( null === $ name && is_a ( $ data , \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile :: class ) ) { /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $data */ $ name = $ data -> getClientOriginalName ( ) ; } if ( $ data instanceof SplFileInfo ) { return $ this -> makeFromFileInfo ( $ data , $ name , $ mimeType ) ; } // Fallback: expect raw or string data, and attempt to interpret it. if ( is_string ( $ data ) ) { $ data = new RawContent ( $ data ) ; } if ( ! ( $ data instanceof RawContentInterface ) ) { throw new UnexpectedValueException ( 'Could not interpret given data, string value expected' ) ; } return $ this -> interpretFromRawContent ( $ data , $ name , $ mimeType ) ; }
Makes a storable file instance from an unknown source type.

@param mixed       $data
@param string|null $name
@param string|null $mimeType
@return StorableFileInterface
@throws CouldNotReadDataException
@throws CouldNotRetrieveRemoteFileException
Makes a storable file instance from an unknown source type .