Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\HttpFoundation\File\MimeType;
13: 
14: use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
15: use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
16: 
17: /**
18:  * Guesses the mime type using the PECL extension FileInfo.
19:  *
20:  * @author Bernhard Schussek <bschussek@gmail.com>
21:  */
22: class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
23: {
24:     private $magicFile;
25: 
26:     /**
27:      * Constructor.
28:      *
29:      * @param string $magicFile A magic file to use with the finfo instance
30:      *
31:      * @link http://www.php.net/manual/en/function.finfo-open.php
32:      */
33:     public function __construct($magicFile = null)
34:     {
35:         $this->magicFile = $magicFile;
36:     }
37: 
38:     /**
39:      * Returns whether this guesser is supported on the current OS/PHP setup.
40:      *
41:      * @return bool
42:      */
43:     public static function isSupported()
44:     {
45:         return function_exists('finfo_open');
46:     }
47: 
48:     /**
49:      * {@inheritdoc}
50:      */
51:     public function guess($path)
52:     {
53:         if (!is_file($path)) {
54:             throw new FileNotFoundException($path);
55:         }
56: 
57:         if (!is_readable($path)) {
58:             throw new AccessDeniedException($path);
59:         }
60: 
61:         if (!self::isSupported()) {
62:             return;
63:         }
64: 
65:         if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) {
66:             return;
67:         }
68: 
69:         return $finfo->file($path);
70:     }
71: }
72: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen