Completed
Push — feature-20rc1 ( 008ae2 )
by Rob
16:55
created

FilePath   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A create() 0 4 1
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\File;
13
14
use Liip\ImagineBundle\File\Attributes\ContentTypeAttribute;
15
use Liip\ImagineBundle\File\Attributes\ExtensionAttribute;
16
17
/**
18
 * @author Rob Frawley 2nd <[email protected]>
19
 */
20
class FilePath extends AbstractFilePath implements FilePathInterface
21
{
22
    /**
23
     * @param string|\SplFileInfo|null  $file
24
     * @param ContentTypeAttribute|null $contentType
25
     * @param ExtensionAttribute|null   $extension
26
     */
27
    public function __construct($file = null, ContentTypeAttribute $contentType = null, ExtensionAttribute $extension = null)
28
    {
29
        parent::__construct($contentType, $extension);
30
31
        if (null !== $file) {
32
            $this->file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
33
        }
34
    }
35
36
    /**
37
     * @param string|null $file
38
     * @param string|null $contentType
39
     * @param string|null $extension
40
     *
41
     * @return self
42
     */
43
    public static function create(string $file = null, string $contentType = null, string $extension = null)
44
    {
45
        return new self($file, ContentTypeAttribute::create($contentType), ExtensionAttribute::create($extension));
46
    }
47
}
48