1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 
<?php
    /**
     * Copyright (C) Apis Networks, Inc - All Rights Reserved.
     *
     * Unauthorized copying of this file, via any medium, is
     * strictly prohibited without consent. Any dissemination of
     * material herein is prohibited.
     *
     * For licensing inquiries email <licensing@apisnetworks.com>
     *
     * Written by Matt Saladna <matt@apisnetworks.com>, September 2017
     */

    trait NamespaceUtilitiesTrait
    {
        /**
         * Get base name from fully-qualified namespace
         *
         * @param string $class optional class resolution override
         * @return string
         */
        public static function getBaseClassName(string $class = null): string
        {
            return (new \ReflectionClass($class ?? static::class))->getShortName();
        }

        /**
         * Append a namespaced class to an existing namespace
         *
         * @param string $class
         * @return string composite fully-qualified class name
         */
        public static function appendNamespace(string $class): string
        {
            return self::getNamespace() . '\\' . $class;
        }

        /**
         * Get namespace from class
         *
         * @param string $class optional class resolution override
         * @return string
         */
        public static function getNamespace(string $class = null): string
        {
            return (new \ReflectionClass($class ?? static::class))->getNamespaceName();
        }
    }