1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 
<?php


namespace Manticoresearch;

/**
 * Result hit object
 * Element of a result set
 * @category ManticoreSearch
 * @package ManticoreSearch
 * @author Adrian Nuta <adrian.nuta@manticoresearch.com>
 * @link https://manticoresearch.com
 */
class ResultHit
{
    private $_data;

    public function __construct($data = [])
    {
        $this->_data = $data;

    }

    public function getId()
    {
        return $this->_data['_id'];
    }

    public function setId($id)
    {
        $this->_data['id'] = $id;
    }

    public function getScore()
    {
        return $this->_data['_score'];
    }

    public function getHighlight()
    {
        return $this->_data['highlight'];
    }

    public function __get(string $key)
    {
        return $this->get($key);
    }

    public function __isset(string $key): bool
    {
        return $this->has($key) && null !== $this->get($key);
    }

    public function get($key)
    {
        if (isset($this->_data['_source'][$key])) {
            return $this->_data['_source'][$key];
        }
        return [];
    }


    public function has($key)
    {
        return isset($this->data['_source'][$key]);
    }

    public function getData()
    {
        return $this->_data['_source'];
    }

}