<commit_before><?php

namespace SimpleNeo4j\ORM;

use SimpleNeo4j\HttpClient;
use SimpleNeo4j\ORM\Exception\ConstraintViolationException;
use SimpleNeo4j\ORM\Exception\ObjectFetchException;

class Manager {

    private $_neo4j_client;

    public function __construct(HttpClient\Client $neo4j_client)
    {
        $this->_neo4j_client = $neo4j_client;
    }

    public function fetchObjectByKey(string $model_class, string $key, $id) : ?ModelAbstract
    {
        $entity = $model_class::ENTITY;

        $query = "MATCH (n:$entity{{$key}:\$id})
                  WITH n, ID(n) as neo4j_id
                  RETURN n{.*, neo4j_id} as info";

        $params = ['id' => $id];

        $result = $this->_neo4j_client->executeQuery($query, $params);

        $result = $result->getSingleResult();

        if (!isset($result[0]['info'])) {
            return null;
        }

        return new $model_class($result[0]['info'], $this);
    }

    public function fetchObjectsByLabel(string $model_class, array $order_by = null, int $limit = null) : array
    {
        $entity = $model_class::ENTITY;<commit_msg>add multi fetch<commit_after><?php

namespace SimpleNeo4j\ORM;

use SimpleNeo4j\HttpClient;
use SimpleNeo4j\ORM\Exception\ConstraintViolationException;
use SimpleNeo4j\ORM\Exception\ObjectFetchException;

class Manager {

    private $_neo4j_client;

    public function __construct(HttpClient\Client $neo4j_client)
    {
        $this->_neo4j_client = $neo4j_client;
    }

    public function fetchObjectByKey(string $model_class, string $key, $id) : ?ModelAbstract
    {
        $entity = $model_class::ENTITY;

        $query = "MATCH (n:$entity{{$key}:\$id})
                  WITH n, ID(n) as neo4j_id
                  RETURN n{.*, neo4j_id} as info";

        $params = ['id' => $id];

        $result = $this->_neo4j_client->executeQuery($query, $params);

        $result = $result->getSingleResult();

        if (!isset($result[0]['info'])) {
            return null;
        }

        return new $model_class($result[0]['info'], $this);
    }

    public function fetchObjectsByKeys(string $model_class, string $key, array $ids) : array
    {
        $entity = $model_class::ENTITY;

        $query = "MATCH (n:$entity)
                  WHERE n.{$key} IN {ids}
                  WITH n, ID(n) as neo4j_id
                  RETURN COLLECT(n{.*, neo4j_id}) as info";

        $params = ['ids' => $ids];

        $result = $this->_neo4j_client->executeQuery($query, $params);

        $result = $result->getSingleResult();

        if (!isset($result[0]['info'])) {
            return [];
        }

        $objects = [];

        foreach ($result[0]['info'] as $info) {
            $objects[] = new $model_class($info, $this);
        }

        return $objects;
    }

    public function fetchObjectsByLabel(string $model_class, array $order_by = null, int $limit = null) : array
    {
        $entity = $model_class::ENTITY;
{'fraction_non_alphanumeric': 0.14184157075152337, 'fraction_numerical': 0.01049424509140149, 'mean_word_length': 2.5774818401937045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2535035', 'n_tokens_mistral': 967, 'n_tokens_neox': 915, 'n_words': 193}