src/Common/Console/Command/Make/Model.php
private function prepareModelName($sModelName): \stdClass
    {
        //  Prepare the supplied model name and test
        $sModelName = preg_replace('/[^a-zA-Z\/ ]/', '', $sModelName);
        $sModelName = preg_replace('/\//', ' \\ ', $sModelName);
        $sModelName = ucwords($sModelName);

        //  Prepare the database table name
        $sTableName = preg_replace('/[^a-z ]/', '', strtolower($sModelName));
        $sTableName = preg_replace('/ +/', '_', $sTableName);
        if (defined('APP_DB_PREFIX')) {
            $sTableNameWithPrefix = APP_DB_PREFIX . $sTableName;
        } else {
            $sTableNameWithPrefix = $sTableName;
        }

        //  Prepare the model name, namespace, filename etc
        $sModelName = 'App\Model\\' . preg_replace('/ /', '', $sModelName);
        $aModelName = explode('\\', $sModelName);
        $aNamespace = array_splice($aModelName, 0, -1);
        $sClassName = implode('', $aModelName);
        $sFilename  = $sClassName . '.php';
        $sPath      = static::MODEL_PATH . implode(DIRECTORY_SEPARATOR, array_slice($aNamespace, 2));
        $sPath      = substr($sPath, -1) !== DIRECTORY_SEPARATOR ? $sPath . DIRECTORY_SEPARATOR : $sPath;
        $sNamespace = implode('\\', $aNamespace);

        //  Set the service name
        $sServiceName = str_replace('App\Model\\', '', $sModelName);
        $sServiceName = str_replace('\\', '', $sServiceName);

        //  Set resource details
        $sResourceNamespace = preg_replace('/^App\\\\Model/', 'App\\Resource', $sNamespace);
        $sResourceClassName = $sClassName;
        $sResourcePath      = static::MODEL_RESOURCE_PATH . implode(DIRECTORY_SEPARATOR, array_slice($aNamespace, 2));
        $sResourcePath      = substr($sResourcePath, -1) !== DIRECTORY_SEPARATOR ? $sResourcePath . DIRECTORY_SEPARATOR : $sResourcePath;
        $sResourceFilename  = $sFilename;


        return (object) [
            'namespace'           => $sNamespace,
            'class_name'          => $sClassName,
            'class_path'          => $sNamespace . '\\' . $sClassName,
            'path'                => $sPath,
            'filename'            => $sFilename,
            'table'               => $sTableName,
            'table_with_prefix'   => $sTableNameWithPrefix,
            'service_name'        => $sServiceName,
            'resource_namespace'  => $sResourceNamespace,
            'resource_class_name' => $sResourceClassName,
            'resource_class_path' => $sResourceNamespace . '\\' . $sResourceClassName,
            'resource_path'       => $sResourcePath,
            'resource_filename'   => $sResourceFilename,
        ];
    }
private function prepareModelName($sModelName): \stdClass
    {
        //  Prepare the supplied model name and test
        $sModelName = preg_replace('/[^a-zA-Z\/ ]/', '', $sModelName);
        $sModelName = preg_replace('/\//', ' \\ ', $sModelName);
        $sModelName = ucwords($sModelName);

        //  Prepare the database table name
        $sTableName = preg_replace('/[^a-z ]/', '', strtolower($sModelName));
        $sTableName = preg_replace('/ +/', '_', $sTableName);
        if (defined('APP_DB_PREFIX')) {
            $sTableNameWithPrefix = APP_DB_PREFIX . $sTableName;
        } else {
            $sTableNameWithPrefix = $sTableName;
        }

        //  Prepare the model name, namespace, filename etc
        $sModelName = 'App\Model\\' . preg_replace('/ /', '', $sModelName);
        $aModelName = explode('\\', $sModelName);
        $aNamespace = array_splice($aModelName, 0, -1);
        $sClassName = implode('', $aModelName);
        $sFilename  = $sClassName . '.php';
        $sPath      = static::MODEL_PATH . implode(DIRECTORY_SEPARATOR, array_slice($aNamespace, 2));
        $sPath      = substr($sPath, -1) !== DIRECTORY_SEPARATOR ? $sPath . DIRECTORY_SEPARATOR : $sPath;
        $sNamespace = implode('\\', $aNamespace);

        //  Set the service name
        $sServiceName = str_replace('App\Model\\', '', $sModelName);
        $sServiceName = str_replace('\\', '', $sServiceName);

        //  Set resource details
        $sResourceNamespace = preg_replace('/^App\\\\Model/', 'App\\Resource', $sNamespace);
        $sResourceClassName = $sClassName;
        $sResourcePath      = static::MODEL_RESOURCE_PATH . implode(DIRECTORY_SEPARATOR, array_slice($aNamespace, 2));
        $sResourcePath      = substr($sResourcePath, -1) !== DIRECTORY_SEPARATOR ? $sResourcePath . DIRECTORY_SEPARATOR : $sResourcePath;
        $sResourceFilename  = $sFilename;


        return (object) [
            'namespace'           => $sNamespace,
            'class_name'          => $sClassName,
            'class_path'          => $sNamespace . '\\' . $sClassName,
            'path'                => $sPath,
            'filename'            => $sFilename,
            'table'               => $sTableName,
            'table_with_prefix'   => $sTableNameWithPrefix,
            'service_name'        => $sServiceName,
            'resource_namespace'  => $sResourceNamespace,
            'resource_class_name' => $sResourceClassName,
            'resource_class_path' => $sResourceNamespace . '\\' . $sResourceClassName,
            'resource_path'       => $sResourcePath,
            'resource_filename'   => $sResourceFilename,
        ];
    }
private function prepareModelName ( $ sModelName ) : \ stdClass { //  Prepare the supplied model name and test $ sModelName = preg_replace ( '/[^a-zA-Z\/ ]/' , '' , $ sModelName ) ; $ sModelName = preg_replace ( '/\//' , ' \\ ' , $ sModelName ) ; $ sModelName = ucwords ( $ sModelName ) ; //  Prepare the database table name $ sTableName = preg_replace ( '/[^a-z ]/' , '' , strtolower ( $ sModelName ) ) ; $ sTableName = preg_replace ( '/ +/' , '_' , $ sTableName ) ; if ( defined ( 'APP_DB_PREFIX' ) ) { $ sTableNameWithPrefix = APP_DB_PREFIX . $ sTableName ; } else { $ sTableNameWithPrefix = $ sTableName ; } //  Prepare the model name, namespace, filename etc $ sModelName = 'App\Model\\' . preg_replace ( '/ /' , '' , $ sModelName ) ; $ aModelName = explode ( '\\' , $ sModelName ) ; $ aNamespace = array_splice ( $ aModelName , 0 , - 1 ) ; $ sClassName = implode ( '' , $ aModelName ) ; $ sFilename = $ sClassName . '.php' ; $ sPath = static :: MODEL_PATH . implode ( DIRECTORY_SEPARATOR , array_slice ( $ aNamespace , 2 ) ) ; $ sPath = substr ( $ sPath , - 1 ) !== DIRECTORY_SEPARATOR ? $ sPath . DIRECTORY_SEPARATOR : $ sPath ; $ sNamespace = implode ( '\\' , $ aNamespace ) ; //  Set the service name $ sServiceName = str_replace ( 'App\Model\\' , '' , $ sModelName ) ; $ sServiceName = str_replace ( '\\' , '' , $ sServiceName ) ; //  Set resource details $ sResourceNamespace = preg_replace ( '/^App\\\\Model/' , 'App\\Resource' , $ sNamespace ) ; $ sResourceClassName = $ sClassName ; $ sResourcePath = static :: MODEL_RESOURCE_PATH . implode ( DIRECTORY_SEPARATOR , array_slice ( $ aNamespace , 2 ) ) ; $ sResourcePath = substr ( $ sResourcePath , - 1 ) !== DIRECTORY_SEPARATOR ? $ sResourcePath . DIRECTORY_SEPARATOR : $ sResourcePath ; $ sResourceFilename = $ sFilename ; return ( object ) [ 'namespace' => $ sNamespace , 'class_name' => $ sClassName , 'class_path' => $ sNamespace . '\\' . $ sClassName , 'path' => $ sPath , 'filename' => $ sFilename , 'table' => $ sTableName , 'table_with_prefix' => $ sTableNameWithPrefix , 'service_name' => $ sServiceName , 'resource_namespace' => $ sResourceNamespace , 'resource_class_name' => $ sResourceClassName , 'resource_class_path' => $ sResourceNamespace . '\\' . $ sResourceClassName , 'resource_path' => $ sResourcePath , 'resource_filename' => $ sResourceFilename , ] ; }
Prepare the model details and do some preliminary checks

@param string $sModelName The name of the model

@return \stdClass
@throws \Exception
Prepare the model details and do some preliminary checks