Cheetah
Autoloader.php
Go to the documentation of this file.
1 <?php
2 
3 namespace OAuth2;
4 
12 {
13  private $dir;
14 
15  public function __construct($dir = null)
16  {
17  if (is_null($dir)) {
18  $dir = dirname(__FILE__).'/..';
19  }
20  $this->dir = $dir;
21  }
25  public static function register($dir = null)
26  {
27  ini_set('unserialize_callback_func', 'spl_autoload_call');
28  spl_autoload_register(array(new self($dir), 'autoload'));
29  }
30 
38  public function autoload($class)
39  {
40  if (0 !== strpos($class, 'OAuth2')) {
41  return;
42  }
43 
44  if (file_exists($file = $this->dir.'/'.str_replace('\\', '/', $class).'.php')) {
45  require $file;
46  }
47  }
48 }
OAuth2\Autoloader
Definition: Autoloader.php:12
php
OAuth2\Autoloader\autoload
autoload($class)
Definition: Autoloader.php:38
OAuth2\Autoloader\__construct
__construct($dir=null)
Definition: Autoloader.php:15
OAuth2
Definition: Autoloader.php:3
$dir
$dir
Definition: config.php:10