From 560a12f0bd6347a335f8ed5201d6d9562d03d4bc Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 3 May 2014 22:24:03 -0400 Subject: Add Google authentication --- vendor/OAuth/Common/AutoLoader.php | 81 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 vendor/OAuth/Common/AutoLoader.php (limited to 'vendor/OAuth/Common/AutoLoader.php') diff --git a/vendor/OAuth/Common/AutoLoader.php b/vendor/OAuth/Common/AutoLoader.php new file mode 100755 index 00000000..9fe7951c --- /dev/null +++ b/vendor/OAuth/Common/AutoLoader.php @@ -0,0 +1,81 @@ + + */ +class AutoLoader +{ + /** + * @var string The namespace prefix for this instance. + */ + protected $namespace = ''; + + /** + * @var string The filesystem prefix to use for this instance + */ + protected $path = ''; + + /** + * Build the instance of the autoloader + * + * @param string $namespace The prefixed namespace this instance will load + * @param string $path The filesystem path to the root of the namespace + */ + public function __construct($namespace, $path) + { + $this->namespace = ltrim($namespace, '\\'); + $this->path = rtrim($path, '/\\') . DIRECTORY_SEPARATOR; + } + + /** + * Try to load a class + * + * @param string $class The class name to load + * + * @return boolean If the loading was successful + */ + public function load($class) + { + $class = ltrim($class, '\\'); + + if (strpos($class, $this->namespace) === 0) { + $nsparts = explode('\\', $class); + $class = array_pop($nsparts); + $nsparts[] = ''; + $path = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts); + $path .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; + + if (file_exists($path)) { + require $path; + + return true; + } + } + + return false; + } + + /** + * Register the autoloader to PHP + * + * @return boolean The status of the registration + */ + public function register() + { + return spl_autoload_register(array($this, 'load')); + } + + /** + * Unregister the autoloader to PHP + * + * @return boolean The status of the unregistration + */ + public function unregister() + { + return spl_autoload_unregister(array($this, 'load')); + } +} -- cgit v1.2.3