src/Utilities/Reflection.php
public static function getClassName($source, $withoutNamespace = false)
    {
        /*
         * First argument is not proper source of class?
         * Nothing to do
         */
        if (empty($source) || (!is_array($source) && !is_object($source) && !is_string($source))) {
            return null;
        }

        $name = '';

        /*
         * An array of objects was provided?
         * Let's use first of them
         */
        if (is_array($source)) {
            $source = Arrays::getFirstElement($source);
        }

        // Let's prepare name of class
        if (is_object($source)) {
            $name = get_class($source);
        } elseif (is_string($source) && (class_exists($source) || trait_exists($source))) {
            $name = $source;
        }

        /*
         * Name of class is still unknown?
         * Nothing to do
         */
        if (empty($name)) {
            return null;
        }

        /*
         * Namespace is not required?
         * Let's return name of class only
         */
        if ($withoutNamespace) {
            $classOnly = Miscellaneous::getLastElementOfString($name, '\\');

            if (null !== $classOnly) {
                $name = $classOnly;
            }

            return $name;
        }

        return static::getRealClass($name);
    }
public static function getClassName($source, $withoutNamespace = false)
    {
        /*
         * First argument is not proper source of class?
         * Nothing to do
         */
        if (empty($source) || (!is_array($source) && !is_object($source) && !is_string($source))) {
            return null;
        }

        $name = '';

        /*
         * An array of objects was provided?
         * Let's use first of them
         */
        if (is_array($source)) {
            $source = Arrays::getFirstElement($source);
        }

        // Let's prepare name of class
        if (is_object($source)) {
            $name = get_class($source);
        } elseif (is_string($source) && (class_exists($source) || trait_exists($source))) {
            $name = $source;
        }

        /*
         * Name of class is still unknown?
         * Nothing to do
         */
        if (empty($name)) {
            return null;
        }

        /*
         * Namespace is not required?
         * Let's return name of class only
         */
        if ($withoutNamespace) {
            $classOnly = Miscellaneous::getLastElementOfString($name, '\\');

            if (null !== $classOnly) {
                $name = $classOnly;
            }

            return $name;
        }

        return static::getRealClass($name);
    }
public static function getClassName ( $ source , $ withoutNamespace = false ) { /*
         * First argument is not proper source of class?
         * Nothing to do
         */ if ( empty ( $ source ) || ( ! is_array ( $ source ) && ! is_object ( $ source ) && ! is_string ( $ source ) ) ) { return null ; } $ name = '' ; /*
         * An array of objects was provided?
         * Let's use first of them
         */ if ( is_array ( $ source ) ) { $ source = Arrays :: getFirstElement ( $ source ) ; } // Let's prepare name of class if ( is_object ( $ source ) ) { $ name = get_class ( $ source ) ; } elseif ( is_string ( $ source ) && ( class_exists ( $ source ) || trait_exists ( $ source ) ) ) { $ name = $ source ; } /*
         * Name of class is still unknown?
         * Nothing to do
         */ if ( empty ( $ name ) ) { return null ; } /*
         * Namespace is not required?
         * Let's return name of class only
         */ if ( $ withoutNamespace ) { $ classOnly = Miscellaneous :: getLastElementOfString ( $ name , '\\' ) ; if ( null !== $ classOnly ) { $ name = $ classOnly ; } return $ name ; } return static :: getRealClass ( $ name ) ; }
Returns a class name for given source

@param array|object|string $source           An array of objects, namespaces, object or namespace
@param bool                $withoutNamespace (optional) If is set to true, namespace is omitted. Otherwise -
not, full name of class is returned, with namespace.
@return null|string
Returns a class name for given source