Mark V
1: <?php
2: namespace MOC\V\Core\AutoLoader\Component\Bridge\Repository;
3:
4: use MOC\V\Core\AutoLoader\Component\Bridge\Bridge;
5: use MOC\V\Core\AutoLoader\Component\IBridgeInterface;
6: use MOC\V\Core\AutoLoader\Component\Parameter\Repository\DirectoryParameter;
7: use MOC\V\Core\AutoLoader\Component\Parameter\Repository\NamespaceParameter;
8: use MOC\V\Core\AutoLoader\Exception\AutoLoaderException;
9: use MOC\V\Core\AutoLoader\Vendor\Multiton\NamespaceLoader;
10:
11: /**
12: * Class MultitonNamespace
13: *
14: * @package MOC\V\Core\AutoLoader\Component\Bridge
15: */
16: class MultitonNamespace extends Bridge implements IBridgeInterface
17: {
18:
19: /** @var NamespaceLoader $Instance */
20: private $Instance = null;
21:
22: /**
23: * @param NamespaceParameter $NamespaceParameter
24: * @param DirectoryParameter $DirectoryParameter
25: * @param NamespaceParameter $PrefixParameter
26: */
27: public function __construct(
28: NamespaceParameter $NamespaceParameter,
29: DirectoryParameter $DirectoryParameter,
30: NamespaceParameter $PrefixParameter = null
31: ) {
32:
33: $this->Instance = new NamespaceLoader(
34: $NamespaceParameter->getNamespace(),
35: $DirectoryParameter->getDirectory(),
36: ( null === $PrefixParameter ? null : $PrefixParameter->getNamespace() )
37: );
38: }
39:
40: /**
41: * @param string $ClassName
42: *
43: * @return bool
44: * @throws AutoLoaderException
45: */
46: public function loadSourceFile($ClassName)
47: {
48:
49: return $this->Instance->loadClass($ClassName);
50: }
51:
52: /**
53: * @param NamespaceParameter $Namespace
54: * @param DirectoryParameter $Directory
55: *
56: * @return IBridgeInterface
57: * @throws AutoLoaderException
58: */
59: public function addNamespaceDirectoryMapping(NamespaceParameter $Namespace, DirectoryParameter $Directory)
60: {
61:
62: throw new AutoLoaderException(__METHOD__.' MUST NOT be used! NS:'.$Namespace.', DIR:'.$Directory);
63: }
64:
65: /**
66: * @return string
67: */
68: public function getLoaderHash()
69: {
70:
71: return $this->Instance->getLoaderHash();
72: }
73: }
74: