Forked from jasondmoss/stripNamespaceFromClassName.php
Created
December 21, 2018 08:12
-
-
Save einnar82/43b67efff803cdac04404db2a18a9472 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