1: <?php
2: /**
3: * Maps classes to paths following the PHP Framework Interop Group PSR-0
4: * reference implementation. Under this guideline, the following rules apply:
5: *
6: * Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
7: * Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
8: * The fully-qualified namespace and class is suffixed with ".php" when loading from the file system.
9: *
10: * Examples:
11: *
12: * \Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
13: * \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
14: * \namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php
15: *
16: * @author Chuck Hagenbuch <chuck@horde.org>
17: * @category Horde
18: * @package Autoloader
19: */
20: class Horde_Autoloader_ClassPathMapper_Default implements Horde_Autoloader_ClassPathMapper
21: {
22: private $_includePath;
23:
24: public function __construct($includePath)
25: {
26: $this->_includePath = $includePath;
27: }
28:
29: public function mapToPath($className)
30: {
31: // @FIXME: Follow reference implementation
32: $relativePath = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $className) . '.php';
33: return $this->_includePath . DIRECTORY_SEPARATOR . $relativePath;
34: }
35: }
36: