<commit_before><?php
/* 
 * Copyright 2014 <NAME> <http://jacksleight.com/>
 * This source file is subject to the MIT license that is bundled with this package in the file LICENCE. 
 */

namespace Coast\Doctrine\ORM;

class EntityManager extends \Doctrine\ORM\Decorator\EntityManagerDecorator implements \Coast\App\Access
{
    use \Coast\App\Access\Implementation;
    
    public function __construct($wraped)
    {
        parent::__construct($wraped);

        $config = $this->getConfiguration();
        $functions = [
            'CEILING'       => 'Coast\Doctrine\ORM\Query\MySql\Ceiling',
            'FIELD'         => 'Coast\Doctrine\ORM\Query\MySql\Field',
            'FLOOR'         => 'Coast\Doctrine\ORM\Query\MySql\Floor',
            'IF'            => 'Coast\Doctrine\ORM\Query\MySql\IfElse',
            'RAND'          => 'Coast\Doctrine\ORM\Query\MySql\Rand',
            'ROUND'         => 'Coast\Doctrine\ORM\Query\MySql\Round',
            'UTC_DATE'      => 'Coast\Doctrine\ORM\Query\MySql\UtcDate',
            'UTC_TIME'      => 'Coast\Doctrine\ORM\Query\MySql\UtcTime',
            'UTC_TIMESTAMP' => 'Coast\Doctrine\ORM\Query\MySql\UtcTimestamp',
        ];
        foreach ($functions as $name => $class) {
            $config->addCustomStringFunction($name, $class);
        }
    } 

    public function getWrapped()
    {
        return $this->wrapped;
    }

    public function call($class)
    {
        return $this->getRepository($class);
    }

    public function isPersisted($entity)
    {
        $uow = $this->getUnitOfWork();
        return $uow->getEntityState($entity) == \Doctrine\ORM\UnitOfWork::STATE_MANAGED;
    }

    public function changes($entity)
    {
        $uow = $this->getUnitOfWork();
        $uow->computeChangeSets();
        return $uow->getEntityChangeSet($entity);
    }
}<commit_msg>Used __invoke when calling objects.<commit_after><?php
/* 
 * Copyright 2014 Jack Sleight <http://jacksleight.com/>
 * This source file is subject to the MIT license that is bundled with this package in the file LICENCE. 
 */

namespace Coast\Doctrine\ORM;

use Doctrine\ORM\QueryBuilder,
    Doctrine\ORM\Query,
    Doctrine\ORM\Tools\Pagination\Paginator;

class EntityManager extends \Doctrine\ORM\Decorator\EntityManagerDecorator implements \Coast\App\Access
{
    use \Coast\App\Access\Implementation;
    
    public function __construct($wraped)
    {
        parent::__construct($wraped);

        $config = $this->getConfiguration();
        $functions = [
            'CEILING'       => 'Coast\Doctrine\ORM\Query\MySql\Ceiling',
            'FIELD'         => 'Coast\Doctrine\ORM\Query\MySql\Field',
            'FLOOR'         => 'Coast\Doctrine\ORM\Query\MySql\Floor',
            'IF'            => 'Coast\Doctrine\ORM\Query\MySql\IfElse',
            'RAND'          => 'Coast\Doctrine\ORM\Query\MySql\Rand',
            'ROUND'         => 'Coast\Doctrine\ORM\Query\MySql\Round',
            'UTC_DATE'      => 'Coast\Doctrine\ORM\Query\MySql\UtcDate',
            'UTC_TIME'      => 'Coast\Doctrine\ORM\Query\MySql\UtcTime',
            'UTC_TIMESTAMP' => 'Coast\Doctrine\ORM\Query\MySql\UtcTimestamp',
        ];
        foreach ($functions as $name => $class) {
            $config->addCustomStringFunction($name, $class);
        }
    } 

    public function getWrapped()
    {
        return $this->wrapped;
    }

    public function __invoke($class)
    {
        return $this->getRepository($class);
    }

    public function isPersisted($entity)
    {
        $uow = $this->getUnitOfWork();
        return $uow->getEntityState($entity) == \Doctrine\ORM\UnitOfWork::STATE_MANAGED;
    }

    public function changes($entity)
    {
        $uow = $this->getUnitOfWork();
        $uow->computeChangeSets();
        return $uow->getEntityChangeSet($entity);
    }

    public function paginate(QueryBuilder $query, $limit, $page)
    {
        $query
            ->setMaxResults($limit)
            ->setFirstResult($limit * ($page - 1));
        $paginator = new Paginator($query->getQuery());
        $paginator->setUseOutputWalkers(false);
        return $paginator;
    }
}
{'fraction_non_alphanumeric': 0.13876174415803422, 'fraction_numerical': 0.0021681522524692846, 'mean_word_length': 2.290015847860539, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 48, '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': '4872479', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1290, 'n_words': 210}