<commit_before><?php

namespace Honeybee\Infrastructure\DataAccess\Finder\Elasticsearch\Projection;

use Honeybee\Common\Error\RuntimeError;
use Honeybee\Infrastructure\Config\ConfigInterface;
use Honeybee\Infrastructure\DataAccess\Connector\ConnectorInterface;
use Honeybee\Infrastructure\DataAccess\Finder\Elasticsearch\ElasticsearchFinder;
use Honeybee\Projection\ProjectionTypeMap;
use Psr\Log\LoggerInterface;

class ProjectionFinder extends ElasticsearchFinder
{
    public function __construct(
        ConnectorInterface $connector,
        ConfigInterface $config,
        LoggerInterface $logger,
        ProjectionTypeMap $projection_type_map
    ) {
        parent::__construct($connector, $config, $logger);

        $this->projection_type_map = $projection_type_map;
    }

    private function createResult(array $document_data)
    {
        $source = $document_data['_source'];
        $event_type = isset($source[self::OBJECT_TYPE]) ? $source[self::OBJECT_TYPE] : false;
        if (!$event_type) {
            throw new RuntimeError('Invalid or corrupt type information within projection data.');
        }
        unset($source[self::OBJECT_TYPE]);

        return $this->projection_type_map->getItem($event_type)->createEntity($source);
    }<commit_msg>add _id to exception to ease error interpretation<commit_after><?php

namespace Honeybee\Infrastructure\DataAccess\Finder\Elasticsearch\Projection;

use Honeybee\Common\Error\RuntimeError;
use Honeybee\Infrastructure\Config\ConfigInterface;
use Honeybee\Infrastructure\DataAccess\Connector\ConnectorInterface;
use Honeybee\Infrastructure\DataAccess\Finder\Elasticsearch\ElasticsearchFinder;
use Honeybee\Projection\ProjectionTypeMap;
use Psr\Log\LoggerInterface;

class ProjectionFinder extends ElasticsearchFinder
{
    public function __construct(
        ConnectorInterface $connector,
        ConfigInterface $config,
        LoggerInterface $logger,
        ProjectionTypeMap $projection_type_map
    ) {
        parent::__construct($connector, $config, $logger);

        $this->projection_type_map = $projection_type_map;
    }

    private function createResult(array $document_data)
    {
        $source = $document_data['_source'];
        $event_type = isset($source[self::OBJECT_TYPE]) ? $source[self::OBJECT_TYPE] : false;
        if (!$event_type) {
            throw new RuntimeError(
                'Invalid or corrupt type information within projection data for _id: ' . @$document_data['_id'] ?: ''
            );
        }
        unset($source[self::OBJECT_TYPE]);

        return $this->projection_type_map->getItem($event_type)->createEntity($source);
    }
{'fraction_non_alphanumeric': 0.10052710843373494, 'fraction_numerical': 0.0, 'mean_word_length': 4.080305927342256, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6349687', 'n_tokens_mistral': 723, 'n_tokens_neox': 735, 'n_words': 131}