code/filesystem/mimetype/mimetype.php
public function fromPath($path)
    {
        if (!is_file($path)) {
            throw new \RuntimeException('File not found at '.$path);
        }

        if (!is_readable($path)) {
            throw new \RuntimeException('File not readable at '.$path);
        }

        $mimetype = null;

        foreach (array_reverse($this->__resolvers) as $name => $resolver)
        {
            //Lazy create the resolver
            if(!($resolver instanceof FilesystemMimetypeInterface))
            {
                $resolver = $this->getObject($resolver);

                if (!$resolver instanceof FilesystemMimetypeInterface) {
                    throw new \UnexpectedValueException('Resolver does not implement FilesystemMimetypeInterface');
                }

                $this->__resolvers[$name] = $resolver;
            }

            /* @var $resolver FilesystemMimetypeInterface */
            if (null !== $mimetype = $resolver->fromPath($path)) {
                break;
            }
        }

        return $mimetype;
    }
public function fromPath($path)
    {
        if (!is_file($path)) {
            throw new \RuntimeException('File not found at '.$path);
        }

        if (!is_readable($path)) {
            throw new \RuntimeException('File not readable at '.$path);
        }

        $mimetype = null;

        foreach (array_reverse($this->__resolvers) as $name => $resolver)
        {
            //Lazy create the resolver
            if(!($resolver instanceof FilesystemMimetypeInterface))
            {
                $resolver = $this->getObject($resolver);

                if (!$resolver instanceof FilesystemMimetypeInterface) {
                    throw new \UnexpectedValueException('Resolver does not implement FilesystemMimetypeInterface');
                }

                $this->__resolvers[$name] = $resolver;
            }

            /* @var $resolver FilesystemMimetypeInterface */
            if (null !== $mimetype = $resolver->fromPath($path)) {
                break;
            }
        }

        return $mimetype;
    }
public function fromPath ( $ path ) { if ( ! is_file ( $ path ) ) { throw new \ RuntimeException ( 'File not found at ' . $ path ) ; } if ( ! is_readable ( $ path ) ) { throw new \ RuntimeException ( 'File not readable at ' . $ path ) ; } $ mimetype = null ; foreach ( array_reverse ( $ this -> __resolvers ) as $ name => $ resolver ) { //Lazy create the resolver if ( ! ( $ resolver instanceof FilesystemMimetypeInterface ) ) { $ resolver = $ this -> getObject ( $ resolver ) ; if ( ! $ resolver instanceof FilesystemMimetypeInterface ) { throw new \ UnexpectedValueException ( 'Resolver does not implement FilesystemMimetypeInterface' ) ; } $ this -> __resolvers [ $ name ] = $ resolver ; } /* @var $resolver FilesystemMimetypeInterface */ if ( null !== $ mimetype = $ resolver -> fromPath ( $ path ) ) { break ; } } return $ mimetype ; }
Tries to find the mime type of the given file from it's file path.

The file is passed to each registered mime type resolver in FILO order. Once a resolver returns a value that
is not NULL, the result is returned.

@param string $path The path to the file
@throws \LogicException   If the file cannot be found
@throws \RuntimeException If the file is not readable
@throws \UnexpectedValueException If the resolver doesn't implement FilesystemMimetypeInterface
@return string The mime type or NULL, if none could be found
Tries to find the mime type of the given file from it s file path .