<commit_before><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Component\CriteriaBuilder;

use Everon\Component\Factory\AbstractWorker;
use Everon\Component\Factory\Exception\UnableToInstantiateException;

class CriteriaBuilderFactoryWorker extends AbstractWorker implements CriteriaBuilderFactoryWorkerInterface
{
    /**
     * @inheritdoc
     */
    public function buildCriteria($namespace='Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Criteria');
            $this->getFactory()->classExists($class_name);
            $Builder = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $Builder);
            return $Builder;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaBuilder($namespace='Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Builder');
            $this->getFactory()->classExists($class_name);
            $Builder = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $Builder);
            return $Builder;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaCriterium($column, $operator, $value, $namespace = 'Everon\Component\CriteriaBuilder\Criteria')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Criterium');
            $this->getFactory()->classExists($class_name);
            $Criterium = new $class_name($column, $operator, $value);
            $this->getFactory()->injectDependencies($class_name, $Criterium);
            return $Criterium;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaContainer(CriteriaInterface $Criteria, $glue, $namespace='Everon\Component\CriteriaBuilder\Criteria')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Container');
            $this->getFactory()->classExists($class_name);
            $Container = new $class_name($Criteria, $glue);
            $this->getFactory()->injectDependencies($class_name, $Container);
            return $Container;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaOperator($type, $namespace='Everon\Component\CriteriaBuilder\Operator')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, $type);
            $this->getFactory()->classExists($class_name);
            $CriteriaOperator = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $CriteriaOperator);
            return $CriteriaOperator;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildSqlPart($sql, array $parameters, $namespace = 'Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'SqlPart');
            $this->getFactory()->classExists($class_name);
            $SqlPart = new $class_name($sql, $parameters);
            $this->getFactory()->injectDependencies($class_name, $SqlPart);
            return $SqlPart;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }
}<commit_msg>$DependencyContainer and $WorkerCollection are static in Factory, added registerBeforeWork() to AbstractWorker, added UtilsFactoryWorkerTest<commit_after><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Component\CriteriaBuilder;

use Everon\Component\Factory\AbstractWorker;
use Everon\Component\Factory\Exception\UnableToInstantiateException;

class CriteriaBuilderFactoryWorker extends AbstractWorker implements CriteriaBuilderFactoryWorkerInterface
{
    /**
     * @inheritdoc
     */
    protected function registerBeforeWork()
    {
        $Factory = $this->getFactory();
        $this->getFactory()->getDependencyContainer()->register('CriteriaBuilderFactoryWorker', function() use ($Factory) {
            return $Factory->getWorkerByName('CriteriaBuilderFactoryWorker', 'Everon\Component\CriteriaBuilder');
        });
    }

    /**
     * @inheritdoc
     */
    public function buildCriteria($namespace='Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Criteria');
            $this->getFactory()->classExists($class_name);
            $Builder = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $Builder);
            return $Builder;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaBuilder($namespace='Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Builder');
            $this->getFactory()->classExists($class_name);
            $Builder = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $Builder);
            return $Builder;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaCriterium($column, $operator, $value, $namespace = 'Everon\Component\CriteriaBuilder\Criteria')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Criterium');
            $this->getFactory()->classExists($class_name);
            $Criterium = new $class_name($column, $operator, $value);
            $this->getFactory()->injectDependencies($class_name, $Criterium);
            return $Criterium;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaContainer(CriteriaInterface $Criteria, $glue, $namespace='Everon\Component\CriteriaBuilder\Criteria')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'Container');
            $this->getFactory()->classExists($class_name);
            $Container = new $class_name($Criteria, $glue);
            $this->getFactory()->injectDependencies($class_name, $Container);
            return $Container;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildCriteriaOperator($type, $namespace='Everon\Component\CriteriaBuilder\Operator')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, $type);
            $this->getFactory()->classExists($class_name);
            $CriteriaOperator = new $class_name();
            $this->getFactory()->injectDependencies($class_name, $CriteriaOperator);
            return $CriteriaOperator;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

    /**
     * @inheritdoc
     */
    public function buildSqlPart($sql, array $parameters, $namespace = 'Everon\Component\CriteriaBuilder')
    {
        try {
            $class_name = $this->getFactory()->getFullClassName($namespace, 'SqlPart');
            $this->getFactory()->classExists($class_name);
            $SqlPart = new $class_name($sql, $parameters);
            $this->getFactory()->injectDependencies($class_name, $SqlPart);
            return $SqlPart;
        }
        catch (\Exception $e) {
            throw new UnableToInstantiateException($e);
        }
    }

}
{'fraction_non_alphanumeric': 0.13105214152700187, 'fraction_numerical': 0.0, 'mean_word_length': 2.587891440501044, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 86, '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': '1440387', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2196, 'n_words': 407}