<commit_before><?php

namespace Shift31;

use Httpful\Request;
use Httpful\Response;

class HostbaseClient
{
	/**
	 * @var string
	 */
	protected $baseUrl;

	/**
	 * @var string
	 */
	protected $resource;

	/**
	 * @var string
	 */
	protected $uri;

	/**
	 * @var null|string
	 */
	protected $username;

	/**
	 * @var null|string
	 */
	protected $password;


	/**
	 * @param string      $baseUrl
	 * @param string      $resource
	 * @param string|null $username
	 * @param string|null $password
	 */
	public function __construct($baseUrl, $resource = 'hosts', $username = null, $password = <PASSWORD>)
	{
		$this->baseUrl = $baseUrl;
		$this->resource = $resource;
		$this->setUri();
		$this->username = $username;
		$this->password = $password;
	}


	protected function setUri()
	{
		$this->uri = "{$this->baseUrl}/{$this->resource}";
	}


	/**
	 * @param $resource
	 *
	 * @return HostbaseClient $this
	 */
	public function setResource($resource)
	{
		$this->resource = $resource;
		$this->setUri();

		return $this;
	}


	/**
	 * @return string
	 */
	public function getResource()
	{
		return $this->resource;
	}


	/**
	 * @param string $query
	 * @param int    $limit
	 *
	 * @throws \Exception
	 * @return array
	 */
	public function search($query, $limit = 10000)
	{
		$response = Request::get("{$this->uri}?q=" . urlencode($query) . "&size=$limit")->authenticateWith(
			$this->username, $this->password
		)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string|null $id
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function show($id = null)
	{
		$uri = $this->uri;

		if ($id != null) {
			$uri .= "/$id";
		}

		$response = Request::get($uri)->authenticateWith($this->username, $this->password)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param array $data
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function store(array $data)
	{
		$response = Request::post($this->uri)
			->authenticateWith($this->username, $this->password)
			->body(json_encode($data))
			->sendsType('application/json')
			->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string $id
	 * @param array  $data
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function update($id, array $data)
	{
		$response = Request::put("{$this->uri}/$id")
			->authenticateWith($this->username, $this->password)
			->body(json_encode($data))
			->sendsType('application/json')
			->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string $id
	 *
	 * @return bool
	 * @throws \Exception
	 */
	public function destroy($id)
	{
		$response = Request::delete("{$this->uri}/$id")->authenticateWith(
			$this->username, $this->password
		)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return true;
		}
	}
}<commit_msg>adding support for hiding data when searching, displaying keys only<commit_after><?php

namespace Shift31;

use Httpful\Request;
use Httpful\Response;

class HostbaseClient
{
	/**
	 * @var string
	 */
	protected $baseUrl;

	/**
	 * @var string
	 */
	protected $resource;

	/**
	 * @var string
	 */
	protected $uri;

	/**
	 * @var null|string
	 */
	protected $username;

	/**
	 * @var null|string
	 */
	protected $password;


	/**
	 * @param string      $baseUrl
	 * @param string      $resource
	 * @param string|null $username
	 * @param string|null $password
	 */
	public function __construct($baseUrl, $resource = 'hosts', $username = null, $password = <PASSWORD>)
	{
		$this->baseUrl = $baseUrl;
		$this->resource = $resource;
		$this->setUri();
		$this->username = $username;
		$this->password = $password;
	}


	protected function setUri()
	{
		$this->uri = "{$this->baseUrl}/{$this->resource}";
	}


	/**
	 * @param $resource
	 *
	 * @return HostbaseClient $this
	 */
	public function setResource($resource)
	{
		$this->resource = $resource;
		$this->setUri();

		return $this;
	}


	/**
	 * @return string
	 */
	public function getResource()
	{
		return $this->resource;
	}


	/**
	 * @param string $query
	 * @param int    $limit
	 * @param bool   $showData
	 *
	 * @throws \Exception
	 * @return array
	 */
	public function search($query, $limit = 10000, $showData = true)
	{
		$response = Request::get("{$this->uri}?q=" . urlencode($query) . "&size=$limit" . "&showData=$showData")
			->authenticateWith($this->username, $this->password
		)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string|null $id
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function show($id = null)
	{
		$uri = $this->uri;

		if ($id != null) {
			$uri .= "/$id";
		}

		$response = Request::get($uri)->authenticateWith($this->username, $this->password)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param array $data
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function store(array $data)
	{
		$response = Request::post($this->uri)
			->authenticateWith($this->username, $this->password)
			->body(json_encode($data))
			->sendsType('application/json')
			->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string $id
	 * @param array  $data
	 *
	 * @return \stdClass
	 * @throws \Exception
	 */
	public function update($id, array $data)
	{
		$response = Request::put("{$this->uri}/$id")
			->authenticateWith($this->username, $this->password)
			->body(json_encode($data))
			->sendsType('application/json')
			->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return $response->body;
		}
	}


	/**
	 * @param string $id
	 *
	 * @return bool
	 * @throws \Exception
	 */
	public function destroy($id)
	{
		$response = Request::delete("{$this->uri}/$id")->authenticateWith(
			$this->username, $this->password
		)->send();

		if ($response instanceof Response && $response->hasErrors()) {
			throw new \Exception($response);
		} else {
			return true;
		}
	}
}
{'fraction_non_alphanumeric': 0.1850697536360938, 'fraction_numerical': 0.0020777678836449986, 'mean_word_length': 3.227728983688833, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 103, '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': '946793', 'n_tokens_mistral': 2502, 'n_tokens_neox': 2162, 'n_words': 489}