<commit_before><?php

/*
 * This file is part of the AdminBundle package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfonian\Indonesia\AdminBundle\Manager;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Symfonian\Indonesia\AdminBundle\Exception\KeyNotMatchException;

/**
 * @author <NAME> <<EMAIL>>
 */
class ManagerFactory
{
    const DOCTRINE_ORM = 'orm';

    const DOCTRINE_ODM = 'odm';

    public static $DRIVERS = array(
        self::DOCTRINE_ORM => 'doctrine',
        self::DOCTRINE_ODM => 'doctrine_mongodb',
    );

    /**
     * @var ObjectManager[]
     */
    private $manager = array();

    /**
     * @param string          $name
     * @param ManagerRegistry $objectManager
     */
    public function addManager($name, ManagerRegistry $objectManager)
    {
        if (!in_array($name, array(self::DOCTRINE_ORM, self::DOCTRINE_ODM))) {
            throw new KeyNotMatchException(sprintf('%s is not valid object managerFactory', $name));
        }

        $this->manager[$name] = $objectManager->getManager();
    }

    /**
     * @param null|string $driver
     *
     * @return ObjectManager
     */
    public function getManager($driver = null)
    {
        if ($driver) {
            return $this->manager[$driver];
        }

        return array_pop($this->manager);
    }
}<commit_msg>bugfix: undefined driver<commit_after><?php

/*
 * This file is part of the AdminBundle package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfonian\Indonesia\AdminBundle\Manager;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Symfonian\Indonesia\AdminBundle\Exception\InvalidArgumentException;
use Symfonian\Indonesia\AdminBundle\Exception\KeyNotMatchException;

/**
 * @author <NAME> <<EMAIL>>
 */
class ManagerFactory
{
    const DOCTRINE_ORM = 'orm';

    const DOCTRINE_ODM = 'odm';

    public static $DRIVERS = array(
        self::DOCTRINE_ORM => 'doctrine',
        self::DOCTRINE_ODM => 'doctrine_mongodb',
    );

    /**
     * @var ObjectManager[]
     */
    private $manager = array();

    /**
     * @param string          $name
     * @param ManagerRegistry $objectManager
     */
    public function addManager($name, ManagerRegistry $objectManager)
    {
        if (!in_array($name, array(self::DOCTRINE_ORM, self::DOCTRINE_ODM))) {
            throw new KeyNotMatchException(sprintf('%s is not valid object managerFactory', $name));
        }

        $this->manager[$name] = $objectManager->getManager();
    }

    /**
     * @param null|string $driver
     *
     * @return ObjectManager
     *
     * @throws InvalidArgumentException
     */
    public function getManager($driver)
    {
        if ($driver) {
            return $this->manager[$driver];
        }

        throw new InvalidArgumentException(sprintf('%s driver not found'));
    }
}
{'fraction_non_alphanumeric': 0.12464409996836444, 'fraction_numerical': 0.0, 'mean_word_length': 2.9133663366336635, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 26, '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': '3070064', 'n_tokens_mistral': 948, 'n_tokens_neox': 932, 'n_words': 217}