<commit_before><?php

namespace PeskyCMF\Db;

use PeskyCMF\Config\CmfConfig;
use PeskyCMF\Scaffold\ScaffoldSectionConfig;
use PeskyORM\Db;
use PeskyORM\DbExpr;
use PeskyORM\DbModel;
use Swayok\Utils\StringUtils;

abstract class CmfDbModel extends DbModel {

    /** @var null|ScaffoldSectionConfig */
    protected $scaffoldConfig = null;
    /** @var array */
    static private $timeZonesList = null;
    /** @var array */
    static private $timeZonesOptions = null;

    static public function getTimezonesList($asOptions = false) {
        if (self::$timeZonesList === null) {
            $ds = self::_getDataSource('default');
            $query = $ds->replaceQuotes(
                DbExpr::create('SELECT * from `pg_timezone_names` ORDER BY `utc_offset` ASC')->get()
            );
            self::$timeZonesList = Db::processRecords($ds->query($query), Db::FETCH_ALL);
        }
        if ($asOptions) {
            if (self::$timeZonesOptions === null) {
                self::$timeZonesOptions = [];
                foreach (self::$timeZonesList as $tzInfo) {
                    $offset = preg_replace('%:\d\d$%', '', $tzInfo['utc_offset']);
                    $offsetPrefix = $offset[0] === '-' ? '' : '+';
                    self::$timeZonesOptions[$tzInfo['name']] = "({$offsetPrefix}{$offset}) {$tzInfo['name']}";
                }
            }
            return self::$timeZonesOptions;
        } else {
            return self::$timeZonesList;
        }
    }

    static public function getModelsNamespace() {
        return call_user_func([get_called_class(), 'getRootNamespace']) . '\\';
    }

    static public function getObjectsNamespace() {
        return call_user_func([get_called_class(), 'getRootNamespace']) . '\\';
    }

    protected function getConfigsNamespace() {
        return $this->getNamespace();
    }

    /**
     * MUST BE OVERRIDEN
     * @return string
     */
    static public function getRootNamespace() {
        return __NAMESPACE__;
    }

    static public function getFullModelClassNameByName($modelNameOrObjectName) {
        /** @var CmfDbModel $calledClass */
        $calledClass = get_called_class();
        $subfolder = preg_replace('%' . $calledClass::$modelClassSuffix . '$%i', '', $modelNameOrObjectName);
        $modelName = $subfolder . $calledClass::$modelClassSuffix;
        $rootNs = call_user_func([$calledClass, 'getRootNamespace']);
        return $rootNs . '\\' . $subfolder . '\\' . $modelName;
    }

    static public function getFullModelClassByTableName($tableName) {
        $rootNs = call_user_func([get_called_class(), 'getRootNamespace']);
        $subfolder = StringUtils::modelize($tableName);
        $modelClassName = call_user_func([get_called_class() ,'getModelNameByTableName'], $tableName);
        return  $rootNs . '\\' . $subfolder . '\\' .$modelClassName;
    }

    static public function getFullDbObjectClass($dbObjectNameOrTableName) {
        /** @var CmfDbModel $calledClass */
        $calledClass = get_called_class();
        $modelClassName = call_user_func(
            [$calledClass, 'getFullModelClassNameByName'],
            StringUtils::modelize($dbObjectNameOrTableName)
        );
        return preg_replace('%' . $calledClass::$modelClassSuffix . '$%', '', $modelClassName);
    }

    /**
     * @return ScaffoldSectionConfig
     */
    public function getScaffoldConfig() {
    }

}<commit_msg>CmfDbModel - fixed getScaffoldConfig() method<commit_after><?php

namespace PeskyCMF\Db;

use PeskyCMF\Config\CmfConfig;
use PeskyCMF\Scaffold\ScaffoldSectionConfig;
use PeskyORM\Db;
use PeskyORM\DbExpr;
use PeskyORM\DbModel;
use Swayok\Utils\StringUtils;

abstract class CmfDbModel extends DbModel {

    /** @var null|ScaffoldSectionConfig */
    protected $scaffoldConfig = null;
    /** @var array */
    static private $timeZonesList = null;
    /** @var array */
    static private $timeZonesOptions = null;

    static public function getTimezonesList($asOptions = false) {
        if (self::$timeZonesList === null) {
            $ds = self::_getDataSource('default');
            $query = $ds->replaceQuotes(
                DbExpr::create('SELECT * from `pg_timezone_names` ORDER BY `utc_offset` ASC')->get()
            );
            self::$timeZonesList = Db::processRecords($ds->query($query), Db::FETCH_ALL);
        }
        if ($asOptions) {
            if (self::$timeZonesOptions === null) {
                self::$timeZonesOptions = [];
                foreach (self::$timeZonesList as $tzInfo) {
                    $offset = preg_replace('%:\d\d$%', '', $tzInfo['utc_offset']);
                    $offsetPrefix = $offset[0] === '-' ? '' : '+';
                    self::$timeZonesOptions[$tzInfo['name']] = "({$offsetPrefix}{$offset}) {$tzInfo['name']}";
                }
            }
            return self::$timeZonesOptions;
        } else {
            return self::$timeZonesList;
        }
    }

    static public function getModelsNamespace() {
        return call_user_func([get_called_class(), 'getRootNamespace']) . '\\';
    }

    static public function getObjectsNamespace() {
        return call_user_func([get_called_class(), 'getRootNamespace']) . '\\';
    }

    protected function getConfigsNamespace() {
        return $this->getNamespace();
    }

    /**
     * MUST BE OVERRIDEN
     * @return string
     */
    static public function getRootNamespace() {
        return __NAMESPACE__;
    }

    static public function getFullModelClassNameByName($modelNameOrObjectName) {
        /** @var CmfDbModel $calledClass */
        $calledClass = get_called_class();
        $subfolder = preg_replace('%' . $calledClass::$modelClassSuffix . '$%i', '', $modelNameOrObjectName);
        $modelName = $subfolder . $calledClass::$modelClassSuffix;
        $rootNs = call_user_func([$calledClass, 'getRootNamespace']);
        return $rootNs . '\\' . $subfolder . '\\' . $modelName;
    }

    static public function getFullModelClassByTableName($tableName) {
        $rootNs = call_user_func([get_called_class(), 'getRootNamespace']);
        $subfolder = StringUtils::modelize($tableName);
        $modelClassName = call_user_func([get_called_class() ,'getModelNameByTableName'], $tableName);
        return  $rootNs . '\\' . $subfolder . '\\' .$modelClassName;
    }

    static public function getFullDbObjectClass($dbObjectNameOrTableName) {
        /** @var CmfDbModel $calledClass */
        $calledClass = get_called_class();
        $modelClassName = call_user_func(
            [$calledClass, 'getFullModelClassNameByName'],
            StringUtils::modelize($dbObjectNameOrTableName)
        );
        return preg_replace('%' . $calledClass::$modelClassSuffix . '$%', '', $modelClassName);
    }

    /**
     * @return ScaffoldSectionConfig
     */
    public function getScaffoldConfig() {
        if (!$this->scaffoldConfig) {
            $this->scaffoldConfig = CmfConfig::getScaffoldConfig($this, $this->getTableName());
        }
        return $this->scaffoldConfig;
    }

}
{'fraction_non_alphanumeric': 0.1421485260770975, 'fraction_numerical': 0.0002834467120181406, 'mean_word_length': 2.7378177966101696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6863289', 'n_tokens_mistral': 2110, 'n_tokens_neox': 2073, 'n_words': 362}