<commit_before><?php namespace Lrezek\Neo4jogm;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use HireVoice\Neo4j\Configuration;
use HireVoice\Neo4j\EntityManager;

use Illuminate\Support\ServiceProvider;

class Neo4jogmServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

    protected $cacheMap = array(
        'array' => '\Doctrine\Common\Cache\ArrayCache',
        'apc' => '\Doctrine\Common\Cache\ApcCache',
        'filesystem' => '\Doctrine\Common\Cache\FilesystemCache',
        'phpFile' => '\Doctrine\Common\Cache\PhpFileCache',
        'winCache' => '\Doctrine\Common\Cache\WinCacheCache',
        'xcache' => '\Doctrine\Common\Cache\XcacheCache',
        'zendData' => '\Doctrine\Common\Cache\ZendDataCache'
    );

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->package('lrezek/neo4jogm');
    }

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{

        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Auto.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Entity.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Index.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToMany.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToOne.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Property.php');

        //$resource = 'database.';
        //$default = $this->app['config']->get($resource . 'default');
        //if (!empty($default) && $default != 'neo4j') {
        //    $resource = 'neo4jogm::';
        //}

	$default = $this->app['config']->get('database.default')
        $settings = $this->app['config']->get('database.connections');

        $config = (!empty($default) && $default == 'neo4j') ? $settings[$default] : $settings;

        if (empty($config['annotation_reader']) && !empty($config['meta_data_cache'])) {
            $metaCache = new $this->cacheMap[$config['meta_data_cache']];
            $metaCache->setNamespace((empty($config['cache_prefix'])) ? 'neo4j' : $config['cache_prefix']);

            $config['annotation_reader'] = new CachedReader(
                new AnnotationReader, $metaCache, false
            );
        }

        $this->app->singleton(
            'entityManager',
            function () use ($config) {
                return new EntityManager(new Configuration($config));
            }
        );

	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array<commit_msg>Code simplification<commit_after><?php namespace Lrezek\Neo4jogm;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use HireVoice\Neo4j\Configuration;
use HireVoice\Neo4j\EntityManager;

use Illuminate\Support\ServiceProvider;

class Neo4jogmServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

    protected $cacheMap = array(
        'array' => '\Doctrine\Common\Cache\ArrayCache',
        'apc' => '\Doctrine\Common\Cache\ApcCache',
        'filesystem' => '\Doctrine\Common\Cache\FilesystemCache',
        'phpFile' => '\Doctrine\Common\Cache\PhpFileCache',
        'winCache' => '\Doctrine\Common\Cache\WinCacheCache',
        'xcache' => '\Doctrine\Common\Cache\XcacheCache',
        'zendData' => '\Doctrine\Common\Cache\ZendDataCache'
    );

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->package('lrezek/neo4jogm');
    }

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{

        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Auto.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Entity.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Index.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToMany.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToOne.php');
        \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Property.php');

	$default = $this->app['config']->get('database.default')
        $settings = $this->app['config']->get('database.connections');

        $config = (!empty($default) && $default == 'neo4j') ? $settings[$default] : $settings;

        if (empty($config['annotation_reader']) && !empty($config['meta_data_cache'])) {
            $metaCache = new $this->cacheMap[$config['meta_data_cache']];
            $metaCache->setNamespace((empty($config['cache_prefix'])) ? 'neo4j' : $config['cache_prefix']);

            $config['annotation_reader'] = new CachedReader(
                new AnnotationReader, $metaCache, false
            );
        }

        $this->app->singleton(
            'entityManager',
            function () use ($config) {
                return new EntityManager(new Configuration($config));
            }
        );

	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
{'fraction_non_alphanumeric': 0.15914114303757498, 'fraction_numerical': 0.006315124723713293, 'mean_word_length': 3.1842800528401587, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '7312968', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1937, 'n_words': 255}