Image::setSplFileInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Rvdlee\ZfImageOptimiser\Model;
4
5
use Rvdlee\ZfImageOptimiser\Exception\InvalidArgumentException;
6
use SplFileInfo;
7
8
class Image
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $path;
14
15
    /**
16
     * @var SplFileInfo
17
     */
18
    protected $splFileInfo;
19
20
    /**
21
     * Image constructor.
22
     *
23
     * @param string $path
24
     *
25
     * @throws InvalidArgumentException
26
     */
27
    public function __construct(string $path)
28
    {
29
        if ( ! file_exists($path)) {
30
            throw new InvalidArgumentException(sprintf('The provided file(%s) does not exist.', $path));
31
        }
32
33
        $this->setPath($path)
34
             ->setSplFileInfo(new SplFileInfo($path));
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getPath() : string
41
    {
42
        return $this->path;
43
    }
44
45
    /**
46
     * @param string $path
47
     *
48
     * @return Image
49
     */
50
    public function setPath(string $path) : Image
51
    {
52
        $this->path = $path;
53
54
        return $this;
55
    }
56
57
    /**
58
     * @return SplFileInfo
59
     */
60
    public function getSplFileInfo() : SplFileInfo
61
    {
62
        return $this->splFileInfo;
63
    }
64
65
    /**
66
     * @param SplFileInfo $splFileInfo
67
     *
68
     * @return Image
69
     */
70
    public function setSplFileInfo(SplFileInfo $splFileInfo) : Image
71
    {
72
        $this->splFileInfo = $splFileInfo;
73
74
        return $this;
75
    }
76
}