<commit_before><?php
namespace Liip\Drupal\Modules\Registry\Lucene;


use Assert\Assertion;
use Elastica\Exception\NotFoundException;
use Liip\Drupal\Modules\Registry\Registry;
use Liip\Drupal\Modules\Registry\RegistryException;
use Liip\Registry\Adaptor\Decorator\DecoratorInterface;
use Liip\Registry\Adaptor\Lucene\AdaptorInterface;
use Liip\Registry\Adaptor\Lucene\ElasticaAdaptor;

class Elasticsearch extends Registry
{
    /**
     * @var \Elastica\Client
     */
    protected $elasticaClient;
    /**
     * @var \Elastica\Index[]
     */
    protected $registry;
    /**
     * @var ElasticaAdaptor
     */
    protected $adaptor;
    /**
     * @var DecoratorInterface
     */
    protected $decorator;

    /**
     * @param string $section
     * @param Assertion $assertion
     * @param DecoratorInterface $decorator
     */
    public function __construct($section, Assertion $assertion, DecoratorInterface $decorator)
    {
        $this->validateElasticaDependency();

        // elastica will complain if the index name is not lowercase.
        $section = strtolower($section);

        parent::__construct($section, $assertion);

        $this->decorator = $decorator;
//        $this->adaptor = $this->getESAdaptor();
//        $this->registry[$section] = $this->adaptor->getIndex($section);
    }

    /**
     * Verifies the existence of the
     * @throws RegistryException
     */
    protected function validateElasticaDependency()
    {
        if (!class_exists('\Elastica\Index')) {

            throw new RegistryException(
                RegistryException::MISSING_DEPENDENCY_TEXT . '(dependency: \Elastica\Index)',
                RegistryException::MISSING_DEPENDENCY_CODE
            );
        }
    }

    /**
     * Provides an instance ot the adaptor e.g. of the Elastica library.
     * @return AdaptorInterface
     */
    public function getESAdaptor()
    {
        if (empty($this->adaptor)) {

            $this->assertion->isInstanceOf(
                $this->decorator,
                '\Liip\Registry\Adaptor\Decorator\DecoratorInterface',
                'Mandatory decorator object is not defined.'<commit_msg>Removed unnecessary lines<commit_after><?php
namespace Liip\Drupal\Modules\Registry\Lucene;


use Assert\Assertion;
use Elastica\Exception\NotFoundException;
use Liip\Drupal\Modules\Registry\Registry;
use Liip\Drupal\Modules\Registry\RegistryException;
use Liip\Registry\Adaptor\Decorator\DecoratorInterface;
use Liip\Registry\Adaptor\Lucene\AdaptorInterface;
use Liip\Registry\Adaptor\Lucene\ElasticaAdaptor;

class Elasticsearch extends Registry
{
    /**
     * @var \Elastica\Client
     */
    protected $elasticaClient;
    /**
     * @var \Elastica\Index[]
     */
    protected $registry;
    /**
     * @var ElasticaAdaptor
     */
    protected $adaptor;
    /**
     * @var DecoratorInterface
     */
    protected $decorator;

    /**
     * @param string $section
     * @param Assertion $assertion
     * @param DecoratorInterface $decorator
     */
    public function __construct($section, Assertion $assertion, DecoratorInterface $decorator)
    {
        $this->validateElasticaDependency();

        // elastica will complain if the index name is not lowercase.
        $section = strtolower($section);

        parent::__construct($section, $assertion);

        $this->decorator = $decorator;
    }

    /**
     * Verifies the existence of the
     * @throws RegistryException
     */
    protected function validateElasticaDependency()
    {
        if (!class_exists('\Elastica\Index')) {

            throw new RegistryException(
                RegistryException::MISSING_DEPENDENCY_TEXT . '(dependency: \Elastica\Index)',
                RegistryException::MISSING_DEPENDENCY_CODE
            );
        }
    }

    /**
     * Provides an instance ot the adaptor e.g. of the Elastica library.
     * @return AdaptorInterface
     */
    public function getESAdaptor()
    {
        if (empty($this->adaptor)) {

            $this->assertion->isInstanceOf(
                $this->decorator,
                '\Liip\Registry\Adaptor\Decorator\DecoratorInterface',
                'Mandatory decorator object is not defined.'
{'fraction_non_alphanumeric': 0.11021377672209026, 'fraction_numerical': 0.0, 'mean_word_length': 2.5327181208053693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '5041628', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1225, 'n_words': 237}