Completed
Pull Request — master (#1213)
by
unknown
01:34
created

FileSystemLoader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.9666
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Binary\Loader;
13
14
use Liip\ImagineBundle\Binary\Locator\LocatorInterface;
15
use Liip\ImagineBundle\Model\FileBinary;
16
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface;
17
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
18
19
class FileSystemLoader implements LoaderInterface
20
{
21
    /**
22
     * @var MimeTypeGuesserInterface
23
     */
24
    protected $mimeTypeGuesser;
25
26
    /**
27
     * @var ExtensionGuesserInterface
28
     */
29
    protected $extensionGuesser;
30
31
    /**
32
     * @var LocatorInterface
33
     */
34
    protected $locator;
35
36
    /**
37
     * @param MimeTypeGuesserInterface  $mimeGuesser
38
     * @param ExtensionGuesserInterface $extensionGuesser
39
     * @param LocatorInterface          $locator
40
     */
41
    public function __construct(
42
        MimeTypeGuesserInterface $mimeGuesser,
43
        ExtensionGuesserInterface $extensionGuesser,
44
        LocatorInterface $locator
45
    ) {
46
        $this->mimeTypeGuesser = $mimeGuesser;
47
        $this->extensionGuesser = $extensionGuesser;
48
        $this->locator = $locator;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function find($path)
55
    {
56
        $path = $this->locator->locate($path);
57
        $mime = $this->mimeTypeGuesser->guess($path);
58
59
        return new FileBinary($path, $mime, $this->extensionGuesser->guess($mime));
60
    }
61
}
62