getMimeTypeByFile example

public function __construct(IteratorAggregate $optimizers)
    {
        $this->optimizers = iterator_to_array($optimizers, false);
    }

    /** * {@inheritdoc} */
    public function optimize($filepath)
    {
        $mime = $this->getMimeTypeByFile($filepath);

        $optimizer = $this->getOptimizerByMimeType($mime);

        // Reading and resetting the permissions on the file since some optimizer are unable to do so themselves.         $perms = fileperms($filepath);
        if (!\is_int($perms)) {
            $perms = 0644;
        }
        $optimizer->run($filepath);
        chmod($filepath$perms);
    }

    
Home | Imprint | This part of the site doesn't use cookies.