1: <?php
2: 3: 4: 5: 6: 7: 8:
9: class Horde_Autoloader_ClassPathMapper_Prefix implements Horde_Autoloader_ClassPathMapper
10: {
11: private $_pattern;
12: private $_includePath;
13:
14: public function __construct($pattern, $includePath)
15: {
16: $this->_pattern = $pattern;
17: $this->_includePath = $includePath;
18: }
19:
20: public function mapToPath($className)
21: {
22: if (preg_match($this->_pattern, $className, $matches, PREG_OFFSET_CAPTURE)) {
23: if (strcasecmp($matches[0][0], $className) === 0) {
24: return "$this->_includePath/$className.php";
25: } else {
26: return str_replace(array('\\', '_'), '/', substr($className, 0, $matches[0][1])) .
27: $this->_includePath . '/' .
28: str_replace(array('\\', '_'), '/', substr($className, $matches[0][1] + strlen($matches[0][0]))) .
29: '.php';
30: }
31: }
32:
33: return false;
34: }
35: }
36: