Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 final class DirectoryContext
00013 {
00014 private $map = array();
00015 private $reverseMap = array();
00016
00017 public function bind($name, $object)
00018 {
00019 if (!is_dir($name))
00020 throw new WrongArgumentException(
00021 'directory '.$name.' does not exists'
00022 );
00023
00024 if (
00025 isset($this->map[$name])
00026 && $this->map[$name] !== $object
00027 )
00028 throw new WrongArgumentException('consider using rebind()');
00029
00030 return $this->rebind($name, $object);
00031 }
00032
00033 public function rebind($name, $object)
00034 {
00035 Assert::isNotNull($object);
00036
00037 $this->map[$name] = $object;
00038 $this->reverseMap[spl_object_hash($object)] = $name;
00039
00040 return $this;
00041 }
00042
00043 public function lookup($name)
00044 {
00045 if (!isset($this->map[$name]))
00046 return null;
00047
00048 return $this->map[$name];
00049 }
00050
00051 public function reverseLookup($object)
00052 {
00053 if (!isset($this->reverseMap[spl_object_hash($object)]))
00054 return null;
00055
00056 return $this->reverseMap[spl_object_hash($object)];
00057 }
00058 }
00059 ?>