find($class))) { require $path; $this->mappings[$class] = $path; } } /** * Find the file associated with a given class name. * * @param string $class * @return string */ protected function find($class) { $file = str_replace('\\', '/', $class); $namespace = substr($class, 0, strpos($class, '\\')); // If the class namespace exists in the libraries array, it means that the // library is PSR-0 compliant, and we will load it following those standards. // This allows us to add many third-party libraries to an application and be // able to auto-load them automatically. if (array_key_exists($namespace, $this->libraries)) { return LIBRARY_PATH.str_replace('_', '/', $file); } foreach ($this->paths as $path) { if (file_exists($path = $path.strtolower($file).EXT)) { return $path; } } // If the namespace exists in the libraries directory, we will assume the // library is PSR-0 compliant, and will add the namespace to the array of // libraries and load the class accordingly. if (is_dir(LIBRARY_PATH.$namespace)) { $this->libraries[] = $namespace; return LIBRARY_PATH.str_replace('_', '/', $file); } } }