Overview

Packages

  • Autoloader

Classes

  • Horde_Autoloader
  • Horde_Autoloader_ClassPathMapper_Application
  • Horde_Autoloader_ClassPathMapper_Default
  • Horde_Autoloader_ClassPathMapper_Prefix
  • Horde_Autoloader_Default

Interfaces

  • Horde_Autoloader_ClassPathMapper
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Load classes from a specific path matching a specific prefix.
 4:  *
 5:  * @author   Chuck Hagenbuch <chuck@horde.org>
 6:  * @category Horde
 7:  * @package  Autoloader
 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: 
API documentation generated by ApiGen