Mark V
1: <?php
2: namespace MOC\V\Component\Document\Component\Parameter\Repository;
3:
4: use MOC\V\Component\Document\Component\Exception\Repository\EmptyFileException;
5: use MOC\V\Component\Document\Component\Exception\Repository\TypeFileException;
6: use MOC\V\Component\Document\Component\IParameterInterface;
7: use MOC\V\Component\Document\Component\Parameter\Parameter;
8:
9: /**
10: * Class FileParameter
11: *
12: * @package MOC\V\Component\Document\Component\Parameter\Repository
13: */
14: class FileParameter extends Parameter implements IParameterInterface
15: {
16:
17: /** @var string $File */
18: private $File = null;
19:
20: /**
21: * @param string $File
22: */
23: public function __construct($File)
24: {
25:
26: $this->setFile((string)$File);
27: }
28:
29: /**
30: * @return \SplFileInfo
31: */
32: public function getFileInfo()
33: {
34:
35: return new \SplFileInfo($this->getFile());
36: }
37:
38: /**
39: * @return string
40: */
41: public function getFile()
42: {
43:
44: return $this->File;
45: }
46:
47: /**
48: * @param string $File
49: *
50: * @throws EmptyFileException
51: * @throws TypeFileException
52: */
53: public function setFile($File)
54: {
55:
56: if (empty( $File )) {
57: throw new EmptyFileException();
58: } else {
59: if (!is_dir($File)) {
60: $this->File = $File;
61: } else {
62: throw new TypeFileException($File.' is a directory!');
63: }
64: }
65: }
66:
67: /**
68: * @return string
69: */
70: public function __toString()
71: {
72:
73: return $this->getFile();
74: }
75: }
76: