commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / vendor / phenx / php-font-lib / src / FontLib / Autoloader.php
1 <?php
2 /**
3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8
9 namespace FontLib;
10
11 /**
12 * Autoloads FontLib classes
13 *
14 * @package php-font-lib
15 */
16 class Autoloader {
17 const PREFIX = 'FontLib';
18
19 /**
20 * Register the autoloader
21 */
22 public static function register() {
23 spl_autoload_register(array(new self, 'autoload'));
24 }
25
26 /**
27 * Autoloader
28 *
29 * @param string
30 */
31 public static function autoload($class) {
32 $prefixLength = strlen(self::PREFIX);
33 if (0 === strncmp(self::PREFIX, $class, $prefixLength)) {
34 $file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
35 $file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
36 if (file_exists($file)) {
37 require_once $file;
38 }
39 }
40 }
41 }
42
43 Autoloader::register();