| Total Complexity | 6 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 |
||
| 75 | } |
||
| 76 | } |