Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inoas/5126ab655ef7794fdb7cf6e3dd2cc64f to your computer and use it in GitHub Desktop.
Save inoas/5126ab655ef7794fdb7cf6e3dd2cc64f to your computer and use it in GitHub Desktop.
Strip the namespace from the class to get the actual class name
<?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