<commit_before><?php
/**
 * @package ulfberht
 * @author <NAME> <<EMAIL>>
 * @link http://ua1.us
 * @copyright Copyright 2016, <NAME>
 * @license MIT
 */

namespace ulfberht\module;

use Exception;
use ulfberht\module\doctrine\config;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Cache\ArrayCache;

/**
 * The purpose of this class is to provide some abstraction to doctrine itself.
 * This object will store all doctrine entity managers.
 */
class doctrine {

    /**
     * @var array This array holds all doctrine entity managers.
     */
    private $_doctrineEntityManagers;

    /**
     * The constructor.
     */
    public function __construct() {
        $this->_doctrineEntityMangers = [];
    }

    /**
     * This method is used to add an entity manager to the doctrine service.
     *
     * @param $id string The id you would like to store with the entity manager.
     * @param ulfberht\module\doctrine\config $config The doctrine configuration for
     *        the entity manager.
     */
    public function addEntityManager($id, config $config) {
        $development = ($config->develop) ? true : false;
        $cache = ($config->enableCache) ? new ArrayCache() : null;

        //setup type of metadata reading
        switch ($config->type) {
            case 'annotation':
                $docConfig = Setup::createAnnotationMetadataConfiguration($this->_config['paths'], $development, null, $cache);
            break;
            case 'xml':
                $docConfig = Setup::createXMLMetadataConfiguration($this->_config['paths'], $development, null, $cache);
            break;
            case 'yaml':
                $docConfig = Setup::createYAMLMetadataConfiguration($this->_config['paths'], $development, null, $cache);
            break;
        }
        
        //setup caching
        if (!is_null($cache)) {
            $docConfig->setQueryCacheImpl($cache);
            $docConfig->setMetadataCacheImpl($cache);
        }

        //setup database connection<commit_msg>Fixed defect of where doctrine was looking for paths.<commit_after><?php
/**
 * @package ulfberht
 * @author <NAME> <<EMAIL>>
 * @link http://ua1.us
 * @copyright Copyright 2016, <NAME>
 * @license MIT
 */

namespace ulfberht\module;

use Exception;
use ulfberht\module\doctrine\config;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Cache\ArrayCache;

/**
 * The purpose of this class is to provide some abstraction to doctrine itself.
 * This object will store all doctrine entity managers.
 */
class doctrine {

    /**
     * @var array This array holds all doctrine entity managers.
     */
    private $_doctrineEntityManagers;

    /**
     * The constructor.
     */
    public function __construct() {
        $this->_doctrineEntityMangers = [];
    }

    /**
     * This method is used to add an entity manager to the doctrine service.
     *
     * @param $id string The id you would like to store with the entity manager.
     * @param ulfberht\module\doctrine\config $config The doctrine configuration for
     *        the entity manager.
     */
    public function addEntityManager($id, config $config) {
        $development = ($config->develop) ? true : false;
        $cache = ($config->enableCache) ? new ArrayCache() : null;

        //setup type of metadata reading
        switch ($config->type) {
            case 'annotation':
                $docConfig = Setup::createAnnotationMetadataConfiguration($config->paths, $development, null, $cache);
            break;
            case 'xml':
                $docConfig = Setup::createXMLMetadataConfiguration($config->paths, $development, null, $cache);
            break;
            case 'yaml':
                $docConfig = Setup::createYAMLMetadataConfiguration($config->paths, $development, null, $cache);
            break;
        }
        
        //setup caching
        if (!is_null($cache)) {
            $docConfig->setQueryCacheImpl($cache);
            $docConfig->setMetadataCacheImpl($cache);
        }

        //setup database connection
{'fraction_non_alphanumeric': 0.11445929526123937, 'fraction_numerical': 0.002430133657351154, 'mean_word_length': 2.494057724957555, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3201195', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1064, 'n_words': 321}