<commit_before><?php

namespace CultuurNet\UDB3\Variations\ReadModel\Search;

use Broadway\EventHandling\EventListenerInterface;
use CultuurNet\UDB3\EventHandling\DelegateEventHandlingToSpecificMethodTrait;
use CultuurNet\UDB3\Variations\Model\Events\OfferVariationCreated;
use CultuurNet\UDB3\Variations\Model\Events\OfferVariationDeleted;

class Projector implements EventListenerInterface
{
    use DelegateEventHandlingToSpecificMethodTrait;

    /**
     * @var RepositoryInterface
     */
    protected $repository;

    /**
     * @param RepositoryInterface $repository
     */
    public function __construct(RepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    protected function applyOfferVariationCreated(OfferVariationCreated $eventVariationCreated)
    {
        $this->repository->save(
            $eventVariationCreated->getId(),
            $eventVariationCreated->getEventUrl(),
            $eventVariationCreated->getOwnerId(),
            $eventVariationCreated->getPurpose()
        );
    }

    protected function applyOfferVariationDeleted(OfferVariationDeleted $eventVariationDeleted)
    {
        $this->repository->remove($eventVariationDeleted->getId());
    }
}<commit_msg>III-666: Fix projector for the search readmodel of variations.<commit_after><?php

namespace CultuurNet\UDB3\Variations\ReadModel\Search;

use Broadway\EventHandling\EventListenerInterface;
use CultuurNet\UDB3\EventHandling\DelegateEventHandlingToSpecificMethodTrait;
use CultuurNet\UDB3\Variations\Model\Events\OfferVariationCreated;
use CultuurNet\UDB3\Variations\Model\Events\OfferVariationDeleted;

class Projector implements EventListenerInterface
{
    use DelegateEventHandlingToSpecificMethodTrait;

    /**
     * @var RepositoryInterface
     */
    protected $repository;

    /**
     * @param RepositoryInterface $repository
     */
    public function __construct(RepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    protected function applyOfferVariationCreated(OfferVariationCreated $eventVariationCreated)
    {
        $this->repository->save(
            $eventVariationCreated->getId(),
            $eventVariationCreated->getEventUrl(),
            $eventVariationCreated->getOwnerId(),
            $eventVariationCreated->getPurpose(),
            $eventVariationCreated->getOfferType()
        );
    }

    protected function applyOfferVariationDeleted(OfferVariationDeleted $eventVariationDeleted)
    {
        $this->repository->remove($eventVariationDeleted->getId());
    }
}
{'fraction_non_alphanumeric': 0.09175377468060394, 'fraction_numerical': 0.004258614014711576, 'mean_word_length': 3.903225806451613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '5991989', 'n_tokens_mistral': 715, 'n_tokens_neox': 710, 'n_words': 97}