Mark V
1: <?php
2: namespace MOC\V\Core\FileSystem\Component\Parameter\Repository;
3:
4: use MOC\V\Core\FileSystem\Component\Exception\Repository\EmptyFileException;
5: use MOC\V\Core\FileSystem\Component\Exception\Repository\TypeFileException;
6: use MOC\V\Core\FileSystem\Component\IParameterInterface;
7: use MOC\V\Core\FileSystem\Component\Parameter\Parameter;
8:
9: /**
10: * Class FileParameter
11: *
12: * @package MOC\V\Core\FileSystem\Component\Parameter\Repository
13: */
14: class FileParameter extends Parameter implements IParameterInterface
15: {
16:
17: /** @var string|null $File */
18: private $File = null;
19:
20: /**
21: * @param string|null $File
22: */
23: public function __construct($File)
24: {
25:
26: $this->setFile($File);
27: }
28:
29: /**
30: * @return string|null
31: */
32: public function getFile()
33: {
34:
35: return $this->File;
36: }
37:
38: /**
39: * @param string|null $File
40: *
41: * @throws EmptyFileException
42: * @throws \MOC\V\Core\FileSystem\Component\Exception\Repository\TypeFileException
43: */
44: public function setFile($File)
45: {
46:
47: if (empty( $File ) && null !== $File) {
48: throw new EmptyFileException();
49: } else {
50: if (!is_dir($File)) {
51: $this->File = $File;
52: } else {
53: throw new TypeFileException($File);
54: }
55: }
56: }
57: }
58: