<commit_before><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2013 <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager as BaseEntityManager;
use Doctrine\Common\Cache\Cache as DoctrineCache;

/**
 * EntityManager
 *
 * @author      <NAME> <<EMAIL>>
 * @method \Doctrine\DBAL\Connection db() Returns the Doctrine DBAL connection object
 * @todo        ohter mapping
 */
class EntityManager extends AbstractWidget
{
    /**
     * Options for configuration
     *
     * @var array
     * @see \Doctrine\ORM\Configuration
     */
    protected $config = array(
        'cache' => null,
        'proxyDir' => null,
        'proxyNamespace' => null,
        'autoGenerateProxyClasses' => null,
        'annotationDriverPaths' => array(),
        'entityNamespaces' => array(),
    );

    /**
     * @var \Doctrine\ORM\EntityManager
     */
    protected $em;

    /**
     * Constructor
     *
     * @param array $options
     */
    public function __construct(array $options = array())
    {
        parent::__construct($options);
        $options = $this->config;

        // create cache object
        switch (true) {
            case is_string($options['cache']) :
                $class = '\Doctrine\Common\Cache\\' . $options['cache'];
                $cache = new $class;
                break;

             case $options['cache'] instanceof DoctrineCache :
                 $cache = $options['cache'];
                 break;

             default :
                 $cache = false;
        }

        $config = new Configuration;

        // set default cache
        if ($cache) {
            $config->setMetadataCacheImpl($cache);
            $config->setQueryCacheImpl($cache);
            $config->setHydrationCacheImpl($cache);
            $config->setResultCacheImpl($cache);
        }

        // todo other driver ?
        if ($options['annotationDriverPaths']) {
            $driverImpl = $config->newDefaultAnnotationDriver($options['annotationDriverPaths'], false);
            $config->setMetadataDriverImpl($driverImpl);
        }

        if ($options['entityNamespaces']) {
            $config->setEntityNamespaces($options['entityNamespaces']);
        }

        // Proxy configuration
        if ($options['proxyDir']) {
            $config->setProxyDir($options['proxyDir']);
        }

        if ($options['proxyNamespace']) {
            $config->setProxyNamespace($options['proxyNamespace']);
        }

        if (is_bool($options['autoGenerateProxyClasses'])) {
            $config->setAutoGenerateProxyClasses($options['autoGenerateProxyClasses']);
        }

        // Create EntityManager
        $this->em = BaseEntityManager::create($this->db(), $config);
    }

    /**
     * Get Docrine ORM entity manager
     *
     * @return \Doctrine\ORM\EntityManager
     */
    public function __invoke()
    {
        return $this->em;
    }

    /**
     * Set options for \Doctrine\ORM\Configuration
     *
     * @param array $config
     * @return EntityManager
     */
    public function setConfig(array $config)
    {
        $this->config = $config + $this->config;

        return $this;
    }
}
<commit_msg>added short description for property<commit_after><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2013 <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager as BaseEntityManager;
use Doctrine\Common\Cache\Cache as DoctrineCache;

/**
 * EntityManager
 *
 * @author      <NAME> <<EMAIL>>
 * @method \Doctrine\DBAL\Connection db() Returns the Doctrine DBAL connection object
 * @todo        ohter mapping
 */
class EntityManager extends AbstractWidget
{
    /**
     * Options for configuration
     *
     * @var array
     * @see \Doctrine\ORM\Configuration
     */
    protected $config = array(
        'cache' => null,
        'proxyDir' => null,
        'proxyNamespace' => null,
        'autoGenerateProxyClasses' => null,
        'annotationDriverPaths' => array(),
        'entityNamespaces' => array(),
    );

    /**
     * The Doctrine ORM entity manager object
     * 
     * @var \Doctrine\ORM\EntityManager
     */
    protected $em;

    /**
     * Constructor
     *
     * @param array $options
     */
    public function __construct(array $options = array())
    {
        parent::__construct($options);
        $options = $this->config;

        // create cache object
        switch (true) {
            case is_string($options['cache']) :
                $class = '\Doctrine\Common\Cache\\' . $options['cache'];
                $cache = new $class;
                break;

             case $options['cache'] instanceof DoctrineCache :
                 $cache = $options['cache'];
                 break;

             default :
                 $cache = false;
        }

        $config = new Configuration;

        // set default cache
        if ($cache) {
            $config->setMetadataCacheImpl($cache);
            $config->setQueryCacheImpl($cache);
            $config->setHydrationCacheImpl($cache);
            $config->setResultCacheImpl($cache);
        }

        // todo other driver ?
        if ($options['annotationDriverPaths']) {
            $driverImpl = $config->newDefaultAnnotationDriver($options['annotationDriverPaths'], false);
            $config->setMetadataDriverImpl($driverImpl);
        }

        if ($options['entityNamespaces']) {
            $config->setEntityNamespaces($options['entityNamespaces']);
        }

        // Proxy configuration
        if ($options['proxyDir']) {
            $config->setProxyDir($options['proxyDir']);
        }

        if ($options['proxyNamespace']) {
            $config->setProxyNamespace($options['proxyNamespace']);
        }

        if (is_bool($options['autoGenerateProxyClasses'])) {
            $config->setAutoGenerateProxyClasses($options['autoGenerateProxyClasses']);
        }

        // Create EntityManager
        $this->em = BaseEntityManager::create($this->db(), $config);
    }

    /**
     * Get Docrine ORM entity manager
     *
     * @return \Doctrine\ORM\EntityManager
     */
    public function __invoke()
    {
        return $this->em;
    }

    /**
     * Set options for \Doctrine\ORM\Configuration
     *
     * @param array $config
     * @return EntityManager
     */
    public function setConfig(array $config)
    {
        $this->config = $config + $this->config;

        return $this;
    }
}

{'fraction_non_alphanumeric': 0.1275797373358349, 'fraction_numerical': 0.002886419396738346, 'mean_word_length': 1.858910891089109, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2857605', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1766, 'n_words': 362}