Mark V
1: <?php
2: namespace MOC\V\Core\AutoLoader\Vendor\Universal\NamespaceLoader;
3:
4: /**
5: * Class NamespaceMapping
6: *
7: * @package MOC\V\Core\AutoLoader\Vendor\Universal
8: */
9: abstract class NamespaceMapping
10: {
11:
12: /** @var array $NamespaceMapping */
13: private $NamespaceMapping = array();
14:
15: /**
16: * @param string $Namespace
17: * @param string $Directory
18: *
19: * @throws \MOC\V\Core\AutoLoader\Component\Exception\Repository\DirectoryNotFoundException
20: */
21: final public function addNamespaceMapping($Namespace, $Directory)
22: {
23:
24: $Directory = realpath($Directory);
25: if (!isset( $this->NamespaceMapping[$Namespace] )) {
26: $this->NamespaceMapping[$Namespace] = array();
27: }
28: $Directory = rtrim(str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $Directory), DIRECTORY_SEPARATOR);
29: if (!in_array($Directory, $this->NamespaceMapping[$Namespace])) {
30: array_push($this->NamespaceMapping[$Namespace], $Directory);
31: }
32: }
33:
34: /**
35: * @param string $Namespace
36: *
37: * @return array
38: */
39: final public function getNamespaceMapping($Namespace)
40: {
41:
42: return isset( $this->NamespaceMapping[$Namespace] ) ? $this->NamespaceMapping[$Namespace] : array();
43: }
44:
45: /**
46: * @return array
47: */
48: final public function getNamespaceList()
49: {
50:
51: return array_keys($this->NamespaceMapping);
52: }
53: }
54: