<commit_before><?php
namespace rjapi\controllers;

use Illuminate\Console\Command;
use rjapi\blocks\Config;
use rjapi\blocks\Middleware;
use rjapi\blocks\Controllers;
use rjapi\blocks\FileManager;
use rjapi\blocks\Entities;
use rjapi\blocks\Migrations;
use rjapi\blocks\Module;
use rjapi\blocks\Routes;
use rjapi\helpers\Console;
use rjapi\types\ConsoleInterface;
use rjapi\types\CustomsInterface;
use rjapi\types\DirsInterface;
use rjapi\types\PhpInterface;
use rjapi\types\RamlInterface;
use Symfony\Component\Yaml\Yaml;

trait ControllersTrait
{
    // dirs
    public $rootDir        = '';
    public $appDir         = '';
    public $modulesDir     = '';
    public $httpDir        = '';
    public $controllersDir = '';
    public $middlewareDir  = '';
    public $entitiesDir    = '';
    public $migrationsDir  = '';

    public $version;
    public $objectName        = '';
    public $defaultController = 'Default';
    public $uriNamedParams    = null;
    public $ramlFile          = '';
    public $force             = null;
    public $customTypes       = [
        CustomsInterface::CUSTOM_TYPES_ID,
        CustomsInterface::CUSTOM_TYPES_TYPE,
        CustomsInterface::CUSTOM_TYPES_RELATIONSHIPS,
    ];
    public $types             = [];
    public $frameWork         = '';
    public $objectProps       = [];
    public $generatedFiles    = [];
    public $relationships     = [];

    private $forms        = null;
    private $controllers  = null;
    private $moduleObject = null;
    private $mappers      = null;
    private $containers   = null;
    private $routes       = null;
    private $migrations   = null;

    private $excludedSubtypes = [
        CustomsInterface::CUSTOM_TYPES_ATTRIBUTES,
        CustomsInterface::CUSTOM_TYPES_RELATIONSHIPS,
        CustomsInterface::CUSTOM_TYPES_QUERY_PARAMS,
        CustomsInterface::CUSTOM_TYPES_FILTER,
    ];

    public $options = [];

    /**
     *  Generates api Controllers + Models to support RAML validation
     */
    public function actionIndex(string $ramlFile)
    {
        $data = Yaml::parse(file_get_contents($ramlFile));
        $this->version        = str_replace('/', '', $data['version']);
        $this->appDir         = DirsInterface::APPLICATION_DIR;
        $this->controllersDir = DirsInterface::CONTROLLERS_DIR;
        $this->entitiesDir    = DirsInterface::ENTITIES_DIR;
        $this->modulesDir     = DirsInterface::MODULES_DIR;
        $this->httpDir        = DirsInterface::HTTP_DIR;
        $this->middlewareDir  = DirsInterface::MIDDLEWARE_DIR;
        $this->migrationsDir  = DirsInterface::MIGRATIONS_DIR;

        if((bool) env('PHP_DEV') === true)
        {
            $this->createDirs();
            $this->options = [
                ConsoleInterface::OPTION_MIGRATIONS => 1,
                ConsoleInterface::OPTION_REGENERATE => 1
            ];
        }
        else
        {
            $this->options = $this->options();
        }
        $this->setIncludedTypes($data);
        $this->runGenerator();
    }

    /**
     *  Main generator method - the sequence of methods execution is crucial
     */
    private function runGenerator()
    {
        $this->generateModule();
        $this->generateConfig();
        foreach($this->types as $objName => $objData)
        {
            if(in_array($objName, $this->customTypes) === false)
            { // if this is not a custom type generate resources
                $excluded = false;
                foreach($this->excludedSubtypes as $type)
                {
                    if(strpos($objName, $type) !== false)
                    {
                        $excluded = true;
                    }
                }
                // if the type is among excluded - continue
                if($excluded === true)
                {
                    continue;
                }
                foreach($objData as $k => $v)
                {
                    if($k === RamlInterface::RAML_PROPS)
                    { // process props
                        $this->setObjectName($objName);
                        $this->setObjectProps($v);
                        $this->generateResources();
                    }
                }
            }
        }
    }

    private function generateModule()<commit_msg>	*	#no-issue. generator scru<commit_after><?php
namespace rjapi\controllers;

use Illuminate\Console\Command;
use rjapi\blocks\Config;
use rjapi\blocks\Middleware;
use rjapi\blocks\Controllers;
use rjapi\blocks\FileManager;
use rjapi\blocks\Entities;
use rjapi\blocks\Migrations;
use rjapi\blocks\Module;
use rjapi\blocks\Routes;
use rjapi\helpers\Console;
use rjapi\types\ConsoleInterface;
use rjapi\types\CustomsInterface;
use rjapi\types\DirsInterface;
use rjapi\types\PhpInterface;
use rjapi\types\RamlInterface;
use Symfony\Component\Yaml\Yaml;

trait ControllersTrait
{
    // dirs
    public $rootDir        = '';
    public $appDir         = '';
    public $modulesDir     = '';
    public $httpDir        = '';
    public $controllersDir = '';
    public $middlewareDir  = '';
    public $entitiesDir    = '';
    public $migrationsDir  = '';

    public $version;
    public $objectName        = '';
    public $defaultController = 'Default';
    public $uriNamedParams    = null;
    public $ramlFile          = '';
    public $force             = null;
    public $customTypes       = [
        CustomsInterface::CUSTOM_TYPES_ID,
        CustomsInterface::CUSTOM_TYPES_TYPE,
        CustomsInterface::CUSTOM_TYPES_RELATIONSHIPS,
    ];
    public $types             = [];
    public $frameWork         = '';
    public $objectProps       = [];
    public $generatedFiles    = [];
    public $relationships     = [];

    private $forms        = null;
    private $controllers  = null;
    private $moduleObject = null;
    private $mappers      = null;
    private $containers   = null;
    private $routes       = null;
    private $migrations   = null;

    private $excludedSubtypes = [
        CustomsInterface::CUSTOM_TYPES_ATTRIBUTES,
        CustomsInterface::CUSTOM_TYPES_RELATIONSHIPS,
        CustomsInterface::CUSTOM_TYPES_QUERY_PARAMS,
        CustomsInterface::CUSTOM_TYPES_FILTER,
    ];

    public $options = [];

    /**
     *  Generates api Controllers + Models to support RAML validation
     */
    public function actionIndex(string $ramlFile)
    {
        $data = Yaml::parse(file_get_contents($ramlFile));
        $this->version        = str_replace('/', '', $data['version']);
        $this->appDir         = DirsInterface::APPLICATION_DIR;
        $this->controllersDir = DirsInterface::CONTROLLERS_DIR;
        $this->entitiesDir    = DirsInterface::ENTITIES_DIR;
        $this->modulesDir     = DirsInterface::MODULES_DIR;
        $this->httpDir        = DirsInterface::HTTP_DIR;
        $this->middlewareDir  = DirsInterface::MIDDLEWARE_DIR;
        $this->migrationsDir  = DirsInterface::MIGRATIONS_DIR;

        if((bool) env('PHP_DEV') === true)
        {
            $this->createDirs();
            $this->options = [
                ConsoleInterface::OPTION_MIGRATIONS => 1,
                ConsoleInterface::OPTION_REGENERATE => 1
            ];
        }
        else
        {
            $this->options = $this->options();
        }
        $this->setIncludedTypes($data);
        $this->runGenerator();
    }

    /**
     *  Main generator method - the sequence of methods execution is crucial
     */
    private function runGenerator()
    {
        $this->generateModule();
        $this->generateConfig();
        foreach($this->types as $objName => $objData)
        {
            if(in_array($objName, $this->customTypes) === false)
            { // if this is not a custom type generate resources
                $excluded = false;
                foreach($this->excludedSubtypes as $type)
                {
                    if(strpos($objName, $type) !== false)
                    {
                        $excluded = true;
                    }
                }
                // if the type is among excluded - continue
                if($excluded === true)
                {
                    continue;
                }
                $this->processObjectData($objName, $objData);
            }
        }
    }

    /**
     * @param string $objName
     * @param array $objData
     */
    private function processObjectData(string $objName, array $objData)
    {
        foreach($objData as $k => $v)
        {
            if($k === RamlInterface::RAML_PROPS)
            { // process props
                $this->setObjectName($objName);
                $this->setObjectProps($v);
                $this->generateResources();
            }
        }
    }

    private function generateModule()
{'fraction_non_alphanumeric': 0.11399612800364423, 'fraction_numerical': 0.0004555289830315454, 'mean_word_length': 1.896437994722955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '4537403', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2522, 'n_words': 462}