Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Maps given class
- *
- * @param string $class Class to map
- *
- * @return boolean Whether class was mapped properly or not
- *
- * @author Manulaiko <manulaiko@gmail.com>
- */
- public function mapNamespace(string $class) : boolean
- {
- //Delete Root namespace
- if(strpos($class, 0, 1) == "\\") {
- $class = substr($class, 1);
- }
- foreach($this->_mappedNamespaces as $mapNamespace => $mapClass) {
- //Check that $class starts with $mapNamespace
- if(strpos($mapNamespace, $class) === 0) {
- //Retrieve $class without $mapNamespace
- $className = substr($class, strlen($mapNamespace));
- //Check that $className isn't a namespace
- if(strpos($className, "\\") !== 0) {
- continue;
- }
- //Add class alias
- class_alias($class, $mapClass);
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement