Forked from jasondmoss/stripNamespaceFromClassName.php
Created
March 2, 2018 17:21
-
-
Save inoas/5126ab655ef7794fdb7cf6e3dd2cc64f to your computer and use it in GitHub Desktop.
Strip the namespace from the class to get the actual class name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Strip the namespace from the class to get the actual class name | |
* | |
* @param string $obj Class name with full namespace | |
* | |
* @return string | |
* @access public | |
*/ | |
function stripNamespaceFromClassName($obj) | |
{ | |
$classname = get_class($obj); | |
if (preg_match('@\\\\([\w]+)$@', $classname, $matches)) { | |
$classname = $matches[1]; | |
} | |
return $classname; | |
} | |
/* <> */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment