<?php

namespace idoit\Module\Search\Query\Engine;

use idoit\Module\Search\Query\Condition;
use idoit\Module\Search\Query\QueryResultItem;

/**
 * i-doit
 *
 * Abstract search query
 *
 * @package     idoit\Module\Search\Index
 * @author      Dennis Stücken <dstuecken@i-doit.com>
 * @version     1.7
 * @copyright   synetics GmbH
 * @license     http://www.i-doit.com/license
 */
abstract class AbstractQuery
{

    /**
     * Get QueryResultItem instance
     *
     * @param string      $type
     * @param int         $id
     * @param string      $key
     * @param string      $value
     * @param double      $score
     * @param Condition[] $conditions
     *
     * @return QueryResultItem
     */
    protected function getQueryItemInstance($type, $id, $key, $value, $score, array $conditions)
    {
        $className = 'idoit\\Module\\' . ucfirst($type) . '\\Search\\Query\\QueryResultItem';

        if (class_exists($className)) {
            return new $className($id, $key, $value, $score, $conditions);
        }

        return new QueryResultItem($id, $key, $value, $score, $conditions);
    }

}
