46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* PHPWord
|
|
*
|
|
* @link https://github.com/PHPOffice/PHPWord
|
|
* @copyright 2014 PHPWord
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
*/
|
|
|
|
namespace PhpOffice\PhpWord;
|
|
|
|
/**
|
|
* Autoloader
|
|
*/
|
|
class Autoloader
|
|
{
|
|
const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\';
|
|
|
|
/**
|
|
* Register
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function register()
|
|
{
|
|
spl_autoload_register(array(new self, 'autoload'));
|
|
}
|
|
|
|
/**
|
|
* Autoload
|
|
*
|
|
* @param string $class
|
|
*/
|
|
public static function autoload($class)
|
|
{
|
|
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
|
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
|
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
|
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
|
if (file_exists($file)) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
}
|
|
}
|