public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $resource = 'http://'.$this->host.static::RESOURCE_LIST;

        if (array_key_exists('directory', $criteria)) {
            $resource .= '/'.$criteria['directory'];
            unset($criteria['directory']);
        }

        $response = $this->client->request('GET', $resource, [
            'headers' => [
                'X-Consul-Token' => $this->token
            ],
            'query' => $criteria
        ]);

        $body = (string) $response->getBody();
        $objects = \GuzzleHttp\json_decode($body);
        $models = new ArrayCollection;

        foreach ($objects as $object) {
            $models->add($this->toModel($object));
        }

        return $models;
    }
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $resource = 'http://'.$this->host.static::RESOURCE_LIST;

        if (array_key_exists('directory', $criteria)) {
            $resource .= '/'.$criteria['directory'];
            unset($criteria['directory']);
        }

        $response = $this->client->request('GET', $resource, [
            'headers' => [
                'X-Consul-Token' => $this->token
            ],
            'query' => $criteria
        ]);

        $body = (string) $response->getBody();
        $objects = \GuzzleHttp\json_decode($body);
        $models = new ArrayCollection;

        foreach ($objects as $object) {
            $models->add($this->toModel($object));
        }

        return $models;
    }
{@inheritdoc}