Mark V
1: <?php
2: namespace MOC\V\Core\AutoLoader\Component\Parameter\Repository;
3:
4: use MOC\V\Core\AutoLoader\Component\Exception\Repository\DirectoryNotFoundException;
5: use MOC\V\Core\AutoLoader\Component\Exception\Repository\EmptyDirectoryException;
6: use MOC\V\Core\AutoLoader\Component\IParameterInterface;
7: use MOC\V\Core\AutoLoader\Component\Parameter\Parameter;
8:
9: /**
10: * Class DirectoryParameter
11: *
12: * @package MOC\V\Core\AutoLoader\Component\Parameter\Repository
13: */
14: class DirectoryParameter extends Parameter implements IParameterInterface
15: {
16:
17: /** @var string $Directory */
18: private $Directory = null;
19:
20: /**
21: * @param string $Directory
22: */
23: public function __construct($Directory)
24: {
25:
26: $this->setDirectory($Directory);
27: }
28:
29: /**
30: * @return string
31: */
32: public function __toString()
33: {
34:
35: return (string)$this->getDirectory();
36: }
37:
38: /**
39: * @return string
40: */
41: public function getDirectory()
42: {
43:
44: return $this->Directory;
45: }
46:
47: /**
48: * @param string $Directory
49: *
50: * @throws EmptyDirectoryException
51: * @throws DirectoryNotFoundException
52: */
53: public function setDirectory($Directory)
54: {
55:
56: if (empty( $Directory )) {
57: throw new EmptyDirectoryException();
58: }
59: $Directory = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $Directory);
60: if (is_dir($Directory)) {
61: $this->Directory = $Directory;
62: } else {
63: throw new DirectoryNotFoundException($Directory);
64: }
65: }
66: }
67: