repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
apisearch-io/php-client | Repository/TransformableRepository.php | TransformableRepository.deleteObject | public function deleteObject($object)
{
$itemUUID = $this
->transformer
->toItemUUID($object);
if ($itemUUID instanceof ItemUUID) {
$this->deleteItem($itemUUID);
}
} | php | public function deleteObject($object)
{
$itemUUID = $this
->transformer
->toItemUUID($object);
if ($itemUUID instanceof ItemUUID) {
$this->deleteItem($itemUUID);
}
} | [
"public",
"function",
"deleteObject",
"(",
"$",
"object",
")",
"{",
"$",
"itemUUID",
"=",
"$",
"this",
"->",
"transformer",
"->",
"toItemUUID",
"(",
"$",
"object",
")",
";",
"if",
"(",
"$",
"itemUUID",
"instanceof",
"ItemUUID",
")",
"{",
"$",
"this",
"... | Delete item document by uuid.
@param mixed $object | [
"Delete",
"item",
"document",
"by",
"uuid",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/TransformableRepository.php#L208-L217 |
apisearch-io/php-client | Exception/InvalidTokenException.php | InvalidTokenException.createInvalidTokenMaxHitsPerQuery | public static function createInvalidTokenMaxHitsPerQuery(
string $tokenReference,
int $maxHitsPerQuery
): self {
return new self(sprintf('Token %s not valid. Max %d hits allowed', $tokenReference, $maxHitsPerQuery));
} | php | public static function createInvalidTokenMaxHitsPerQuery(
string $tokenReference,
int $maxHitsPerQuery
): self {
return new self(sprintf('Token %s not valid. Max %d hits allowed', $tokenReference, $maxHitsPerQuery));
} | [
"public",
"static",
"function",
"createInvalidTokenMaxHitsPerQuery",
"(",
"string",
"$",
"tokenReference",
",",
"int",
"$",
"maxHitsPerQuery",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"sprintf",
"(",
"'Token %s not valid. Max %d hits allowed'",
",",
"$",
... | Throw an invalid key exception.
@param string $tokenReference
@param int $maxHitsPerQuery
@return InvalidTokenException | [
"Throw",
"an",
"invalid",
"key",
"exception",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exception/InvalidTokenException.php#L53-L58 |
apisearch-io/php-client | Model/Item.php | Item.create | public static function create(
ItemUUID $uuid,
array $metadata = [],
array $indexedMetadata = [],
array $searchableMetadata = [],
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
$uuid,
null,
$meta... | php | public static function create(
ItemUUID $uuid,
array $metadata = [],
array $indexedMetadata = [],
array $searchableMetadata = [],
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
$uuid,
null,
$meta... | [
"public",
"static",
"function",
"create",
"(",
"ItemUUID",
"$",
"uuid",
",",
"array",
"$",
"metadata",
"=",
"[",
"]",
",",
"array",
"$",
"indexedMetadata",
"=",
"[",
"]",
",",
"array",
"$",
"searchableMetadata",
"=",
"[",
"]",
",",
"array",
"$",
"exact... | Create.
@param ItemUUID $uuid
@param array $metadata
@param array $indexedMetadata
@param array $searchableMetadata
@param array $exactMatchingMetadata
@param array $suggest
@return Item | [
"Create",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Item.php#L143-L160 |
apisearch-io/php-client | Model/Item.php | Item.createLocated | public static function createLocated(
ItemUUID $uuid,
Coordinate $coordinate,
array $metadata = [],
array $indexedMetadata = [],
array $searchableMetadata = [],
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
$uu... | php | public static function createLocated(
ItemUUID $uuid,
Coordinate $coordinate,
array $metadata = [],
array $indexedMetadata = [],
array $searchableMetadata = [],
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
$uu... | [
"public",
"static",
"function",
"createLocated",
"(",
"ItemUUID",
"$",
"uuid",
",",
"Coordinate",
"$",
"coordinate",
",",
"array",
"$",
"metadata",
"=",
"[",
"]",
",",
"array",
"$",
"indexedMetadata",
"=",
"[",
"]",
",",
"array",
"$",
"searchableMetadata",
... | Create located.
@param ItemUUID $uuid
@param Coordinate $coordinate
@param array $metadata
@param array $indexedMetadata
@param array $searchableMetadata
@param array $exactMatchingMetadata
@param array $suggest
@return Item | [
"Create",
"located",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Item.php#L175-L193 |
apisearch-io/php-client | Model/Item.php | Item.getHighlight | public function getHighlight(string $fieldName): ? string
{
return isset($this->highlights[$fieldName])
? ((string) $this->highlights[$fieldName])
: null;
} | php | public function getHighlight(string $fieldName): ? string
{
return isset($this->highlights[$fieldName])
? ((string) $this->highlights[$fieldName])
: null;
} | [
"public",
"function",
"getHighlight",
"(",
"string",
"$",
"fieldName",
")",
":",
"?",
"string",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"highlights",
"[",
"$",
"fieldName",
"]",
")",
"?",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"highlights"... | Get Highlights.
@param string $fieldName
@return string|null | [
"Get",
"Highlights",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Item.php#L433-L438 |
apisearch-io/php-client | Model/Item.php | Item.toArray | public function toArray(): array
{
return array_filter([
'uuid' => $this->uuid->toArray(),
'coordinate' => $this->coordinate instanceof Coordinate
? $this->coordinate->toArray()
: null,
'distance' => $this->distance,
'metadata' ... | php | public function toArray(): array
{
return array_filter([
'uuid' => $this->uuid->toArray(),
'coordinate' => $this->coordinate instanceof Coordinate
? $this->coordinate->toArray()
: null,
'distance' => $this->distance,
'metadata' ... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'uuid'",
"=>",
"$",
"this",
"->",
"uuid",
"->",
"toArray",
"(",
")",
",",
"'coordinate'",
"=>",
"$",
"this",
"->",
"coordinate",
"instanceof",
"Coordinate",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Item.php#L497-L520 |
apisearch-io/php-client | Model/Item.php | Item.createFromArray | public static function createFromArray(array $array): self
{
if (
!isset($array['uuid']) ||
!is_array($array['uuid'])
) {
throw InvalidFormatException::itemUUIDRepresentationNotValid($array['uuid'] ?? []);
}
if (
isset($array['coordina... | php | public static function createFromArray(array $array): self
{
if (
!isset($array['uuid']) ||
!is_array($array['uuid'])
) {
throw InvalidFormatException::itemUUIDRepresentationNotValid($array['uuid'] ?? []);
}
if (
isset($array['coordina... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"'uuid'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"array",
"[",
"'uuid'",
"]",
")",
")",
"{",
... | Create from array.
@param array $array
@return Item | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Item.php#L529-L581 |
apisearch-io/php-client | Repository/RepositoryBucket.php | RepositoryBucket.addRepository | public function addRepository(
string $appName,
string $indexName,
TransformableRepository $repository
) {
$this->repositories[$appName][$indexName] = $repository;
} | php | public function addRepository(
string $appName,
string $indexName,
TransformableRepository $repository
) {
$this->repositories[$appName][$indexName] = $repository;
} | [
"public",
"function",
"addRepository",
"(",
"string",
"$",
"appName",
",",
"string",
"$",
"indexName",
",",
"TransformableRepository",
"$",
"repository",
")",
"{",
"$",
"this",
"->",
"repositories",
"[",
"$",
"appName",
"]",
"[",
"$",
"indexName",
"]",
"=",
... | Add repository.
@param string $appName
@param string $indexName
@param TransformableRepository $repository | [
"Add",
"repository",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryBucket.php#L37-L43 |
apisearch-io/php-client | Repository/RepositoryBucket.php | RepositoryBucket.findRepository | public function findRepository(
string $appName,
string $indexName
): ? TransformableRepository {
if (
!isset($this->repositories[$appName]) ||
!isset($this->repositories[$appName][$indexName])
) {
return null;
}
return $this->repo... | php | public function findRepository(
string $appName,
string $indexName
): ? TransformableRepository {
if (
!isset($this->repositories[$appName]) ||
!isset($this->repositories[$appName][$indexName])
) {
return null;
}
return $this->repo... | [
"public",
"function",
"findRepository",
"(",
"string",
"$",
"appName",
",",
"string",
"$",
"indexName",
")",
":",
"?",
"TransformableRepository",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"appName",
"]",
")",
"||",
"... | Get repository by name and index.
@param string $appName
@param string $indexName
@return TransformableRepository|null | [
"Get",
"repository",
"by",
"name",
"and",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryBucket.php#L53-L65 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.createFieldBoosting | public static function createFieldBoosting(
string $field,
float $factor = self::DEFAULT_FACTOR,
float $missing = self::DEFAULT_MISSING,
string $modifier = self::MODIFIER_NONE,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::... | php | public static function createFieldBoosting(
string $field,
float $factor = self::DEFAULT_FACTOR,
float $missing = self::DEFAULT_MISSING,
string $modifier = self::MODIFIER_NONE,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::... | [
"public",
"static",
"function",
"createFieldBoosting",
"(",
"string",
"$",
"field",
",",
"float",
"$",
"factor",
"=",
"self",
"::",
"DEFAULT_FACTOR",
",",
"float",
"$",
"missing",
"=",
"self",
"::",
"DEFAULT_MISSING",
",",
"string",
"$",
"modifier",
"=",
"se... | Create default field scoring.
@param string $field
@param float $factor
@param float $missing
@param string $modifier
@param float $weight
@param Filter $filter
@param string $scoreMode
@return ScoreStrategy | [
"Create",
"default",
"field",
"scoring",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L275-L295 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.createCustomFunction | public static function createCustomFunction(
string $function,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::SCORE_MODE_AVG
): ScoreStrategy {
$scoreStrategy = self::createDefault();
$scoreStrategy->type = self::CUSTOM_FUNCTION... | php | public static function createCustomFunction(
string $function,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::SCORE_MODE_AVG
): ScoreStrategy {
$scoreStrategy = self::createDefault();
$scoreStrategy->type = self::CUSTOM_FUNCTION... | [
"public",
"static",
"function",
"createCustomFunction",
"(",
"string",
"$",
"function",
",",
"float",
"$",
"weight",
"=",
"self",
"::",
"DEFAULT_WEIGHT",
",",
"Filter",
"$",
"filter",
"=",
"null",
",",
"string",
"$",
"scoreMode",
"=",
"self",
"::",
"SCORE_MO... | Create custom function scoring.
@param string $function
@param float $weight
@param Filter $filter
@param string $scoreMode
@return ScoreStrategy | [
"Create",
"custom",
"function",
"scoring",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L307-L321 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.createDecayFunction | public static function createDecayFunction(
string $type,
string $field,
string $origin,
string $scale,
string $offset,
float $decay,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::SCORE_MODE_AVG
): Score... | php | public static function createDecayFunction(
string $type,
string $field,
string $origin,
string $scale,
string $offset,
float $decay,
float $weight = self::DEFAULT_WEIGHT,
Filter $filter = null,
string $scoreMode = self::SCORE_MODE_AVG
): Score... | [
"public",
"static",
"function",
"createDecayFunction",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"field",
",",
"string",
"$",
"origin",
",",
"string",
"$",
"scale",
",",
"string",
"$",
"offset",
",",
"float",
"$",
"decay",
",",
"float",
"$",
"weigh... | Create custom function scoring.
@param string $type
@param string $field
@param string $origin
@param string $scale
@param string $offset
@param float $decay
@param float $weight
@param Filter $filter
@param string $scoreMode
@return ScoreStrategy | [
"Create",
"custom",
"function",
"scoring",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L338-L362 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.fixFilterFieldPath | private static function fixFilterFieldPath(?Filter $filter): ? Filter
{
if (is_null($filter)) {
return $filter;
}
$filterAsArray = $filter->toArray();
$filterAsArray['field'] = Item::getPathByField($filterAsArray['field']);
return Filter::createFromArray($filter... | php | private static function fixFilterFieldPath(?Filter $filter): ? Filter
{
if (is_null($filter)) {
return $filter;
}
$filterAsArray = $filter->toArray();
$filterAsArray['field'] = Item::getPathByField($filterAsArray['field']);
return Filter::createFromArray($filter... | [
"private",
"static",
"function",
"fixFilterFieldPath",
"(",
"?",
"Filter",
"$",
"filter",
")",
":",
"?",
"Filter",
"{",
"if",
"(",
"is_null",
"(",
"$",
"filter",
")",
")",
"{",
"return",
"$",
"filter",
";",
"}",
"$",
"filterAsArray",
"=",
"$",
"filter"... | Fix filter path.
@param Filter|null $filter
@return Filter | [
"Fix",
"filter",
"path",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L371-L381 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.toArray | public function toArray(): array
{
return [
'type' => $this->type,
'configuration' => $this->configuration,
'weight' => $this->weight,
'score_mode' => $this->scoreMode,
'filter' => ($this->filter instanceof Filter
? $this
... | php | public function toArray(): array
{
return [
'type' => $this->type,
'configuration' => $this->configuration,
'weight' => $this->weight,
'score_mode' => $this->scoreMode,
'filter' => ($this->filter instanceof Filter
? $this
... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"type",
",",
"'configuration'",
"=>",
"$",
"this",
"->",
"configuration",
",",
"'weight'",
"=>",
"$",
"this",
"->",
"weight",
",",
"'score_mod... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L388-L401 |
apisearch-io/php-client | Query/ScoreStrategy.php | ScoreStrategy.createFromArray | public static function createFromArray(array $array)
{
$scoreStrategy = new self();
$scoreStrategy->type = $array['type'] ?: self::DEFAULT_TYPE;
$scoreStrategy->configuration = $array['configuration'] ?? [];
$scoreStrategy->weight = $array['weight'] ?? self::DEFAULT_WEIGHT;
$... | php | public static function createFromArray(array $array)
{
$scoreStrategy = new self();
$scoreStrategy->type = $array['type'] ?: self::DEFAULT_TYPE;
$scoreStrategy->configuration = $array['configuration'] ?? [];
$scoreStrategy->weight = $array['weight'] ?? self::DEFAULT_WEIGHT;
$... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"scoreStrategy",
"=",
"new",
"self",
"(",
")",
";",
"$",
"scoreStrategy",
"->",
"type",
"=",
"$",
"array",
"[",
"'type'",
"]",
"?",
":",
"self",
"::",
"DEFAUL... | Create from array.
@param array $array
@return self | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategy.php#L410-L422 |
apisearch-io/php-client | Result/Counter.php | Counter.createByActiveElements | public static function createByActiveElements(
string $name,
int $n,
array $activeElements
): ? self {
$values = Metadata::fromMetadata($name);
if (is_null($values)) {
return null;
}
return new self(
$values,
in_array($val... | php | public static function createByActiveElements(
string $name,
int $n,
array $activeElements
): ? self {
$values = Metadata::fromMetadata($name);
if (is_null($values)) {
return null;
}
return new self(
$values,
in_array($val... | [
"public",
"static",
"function",
"createByActiveElements",
"(",
"string",
"$",
"name",
",",
"int",
"$",
"n",
",",
"array",
"$",
"activeElements",
")",
":",
"?",
"self",
"{",
"$",
"values",
"=",
"Metadata",
"::",
"fromMetadata",
"(",
"$",
"name",
")",
";",... | Create or return null if the used element is not valid.
@param string $name
@param int $n
@param array $activeElements
@return Counter|null | [
"Create",
"or",
"return",
"null",
"if",
"the",
"used",
"element",
"is",
"not",
"valid",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Counter.php#L143-L159 |
apisearch-io/php-client | Model/Token.php | Token.toArray | public function toArray(): array
{
return [
'uuid' => $this->tokenUUID->toArray(),
'app_uuid' => $this->appUUID->toArray(),
'created_at' => $this->createdAt,
'updated_at' => $this->updatedAt,
'indices' => array_map(function (IndexUUID $indexUUID) {... | php | public function toArray(): array
{
return [
'uuid' => $this->tokenUUID->toArray(),
'app_uuid' => $this->appUUID->toArray(),
'created_at' => $this->createdAt,
'updated_at' => $this->updatedAt,
'indices' => array_map(function (IndexUUID $indexUUID) {... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'uuid'",
"=>",
"$",
"this",
"->",
"tokenUUID",
"->",
"toArray",
"(",
")",
",",
"'app_uuid'",
"=>",
"$",
"this",
"->",
"appUUID",
"->",
"toArray",
"(",
")",
",",
"'created_at'... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Token.php#L314-L329 |
apisearch-io/php-client | Model/Token.php | Token.createFromArray | public static function createFromArray(array $array)
{
if (
!isset($array['uuid']) ||
!isset($array['app_uuid'])
) {
throw InvalidFormatException::tokenFormatNotValid(json_encode($array));
}
$token = new self(
TokenUUID::createFromArra... | php | public static function createFromArray(array $array)
{
if (
!isset($array['uuid']) ||
!isset($array['app_uuid'])
) {
throw InvalidFormatException::tokenFormatNotValid(json_encode($array));
}
$token = new self(
TokenUUID::createFromArra... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"'uuid'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"array",
"[",
"'app_uuid'",
"]",
")",
")",
"{",
"throw",
"In... | Create from array.
@param array $array
@return self
@throws InvalidFormatException | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Token.php#L340-L365 |
apisearch-io/php-client | Exporter/CSVExporter.php | CSVExporter.itemsToFormat | public function itemsToFormat(array $items): string
{
return $this->strToCSV(array_map(function (Item $item) {
return [
$item->getId(),
$item->getType(),
json_encode($item->getMetadata()),
json_encode($item->getIndexedMetadata()),
... | php | public function itemsToFormat(array $items): string
{
return $this->strToCSV(array_map(function (Item $item) {
return [
$item->getId(),
$item->getType(),
json_encode($item->getMetadata()),
json_encode($item->getIndexedMetadata()),
... | [
"public",
"function",
"itemsToFormat",
"(",
"array",
"$",
"items",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"strToCSV",
"(",
"array_map",
"(",
"function",
"(",
"Item",
"$",
"item",
")",
"{",
"return",
"[",
"$",
"item",
"->",
"getId",
"(",
... | Convert array of Items to string format.
@param Item[] $items
@return string | [
"Convert",
"array",
"of",
"Items",
"to",
"string",
"format",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/CSVExporter.php#L53-L71 |
apisearch-io/php-client | Exporter/CSVExporter.php | CSVExporter.formatToItems | public function formatToItems(string $data): array
{
return array_map(function (string $line) {
$item = str_getcsv($line, ',');
$itemAsArray = [
'uuid' => [
'id' => $item[0],
'type' => $item[1],
],
... | php | public function formatToItems(string $data): array
{
return array_map(function (string $line) {
$item = str_getcsv($line, ',');
$itemAsArray = [
'uuid' => [
'id' => $item[0],
'type' => $item[1],
],
... | [
"public",
"function",
"formatToItems",
"(",
"string",
"$",
"data",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"string",
"$",
"line",
")",
"{",
"$",
"item",
"=",
"str_getcsv",
"(",
"$",
"line",
",",
"','",
")",
";",
"$",
"ite... | Convert string formatted to array of Items.
@param string $data
@return Item[] | [
"Convert",
"string",
"formatted",
"to",
"array",
"of",
"Items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/CSVExporter.php#L80-L102 |
apisearch-io/php-client | Exporter/CSVExporter.php | CSVExporter.strToCSV | private function strToCSV(
array $items,
string $delimiter = ',',
string $enclosure = '"'
) {
$fp = fopen('php://temp', 'r+b');
foreach ($items as $item) {
fputcsv($fp, $item, $delimiter, $enclosure);
}
rewind($fp);
$data = rtrim(stream_get... | php | private function strToCSV(
array $items,
string $delimiter = ',',
string $enclosure = '"'
) {
$fp = fopen('php://temp', 'r+b');
foreach ($items as $item) {
fputcsv($fp, $item, $delimiter, $enclosure);
}
rewind($fp);
$data = rtrim(stream_get... | [
"private",
"function",
"strToCSV",
"(",
"array",
"$",
"items",
",",
"string",
"$",
"delimiter",
"=",
"','",
",",
"string",
"$",
"enclosure",
"=",
"'\"'",
")",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"'php://temp'",
",",
"'r+b'",
")",
";",
"foreach",
"(",
... | @param array $items
@param string $delimiter
@param string $enclosure
@return string | [
"@param",
"array",
"$items",
"@param",
"string",
"$delimiter",
"@param",
"string",
"$enclosure"
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/CSVExporter.php#L111-L125 |
apisearch-io/php-client | Repository/RepositoryReference.php | RepositoryReference.create | public static function create(
AppUUID $appUUID = null,
IndexUUID $indexUUID = null
): RepositoryReference {
return new self($appUUID, $indexUUID);
} | php | public static function create(
AppUUID $appUUID = null,
IndexUUID $indexUUID = null
): RepositoryReference {
return new self($appUUID, $indexUUID);
} | [
"public",
"static",
"function",
"create",
"(",
"AppUUID",
"$",
"appUUID",
"=",
"null",
",",
"IndexUUID",
"$",
"indexUUID",
"=",
"null",
")",
":",
"RepositoryReference",
"{",
"return",
"new",
"self",
"(",
"$",
"appUUID",
",",
"$",
"indexUUID",
")",
";",
"... | Create by appUUID and indexUUID.
@param AppUUID $appUUID
@param IndexUUID $indexUUID
@return RepositoryReference | [
"Create",
"by",
"appUUID",
"and",
"indexUUID",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryReference.php#L82-L87 |
apisearch-io/php-client | Repository/RepositoryReference.php | RepositoryReference.compose | public function compose(): string
{
return sprintf('%s_%s',
$this->appUUID instanceof AppUUID
? str_replace('_', '-', $this->appUUID->composeUUID())
: '',
$this->indexUUID instanceof IndexUUID
? str_replace('_', '-', $this->indexUUID->c... | php | public function compose(): string
{
return sprintf('%s_%s',
$this->appUUID instanceof AppUUID
? str_replace('_', '-', $this->appUUID->composeUUID())
: '',
$this->indexUUID instanceof IndexUUID
? str_replace('_', '-', $this->indexUUID->c... | [
"public",
"function",
"compose",
"(",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"'%s_%s'",
",",
"$",
"this",
"->",
"appUUID",
"instanceof",
"AppUUID",
"?",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"$",
"this",
"->",
"appUUID",
"->",
"composeU... | Compose.
@return string | [
"Compose",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryReference.php#L109-L119 |
apisearch-io/php-client | Repository/RepositoryReference.php | RepositoryReference.createFromComposed | public static function createFromComposed(string $composed): RepositoryReference
{
list($appUUIDComposed, $indexUUIDComposed) = explode('_', $composed, 2);
return RepositoryReference::create(
AppUUID::createById($appUUIDComposed),
IndexUUID::createById($indexUUIDComposed)
... | php | public static function createFromComposed(string $composed): RepositoryReference
{
list($appUUIDComposed, $indexUUIDComposed) = explode('_', $composed, 2);
return RepositoryReference::create(
AppUUID::createById($appUUIDComposed),
IndexUUID::createById($indexUUIDComposed)
... | [
"public",
"static",
"function",
"createFromComposed",
"(",
"string",
"$",
"composed",
")",
":",
"RepositoryReference",
"{",
"list",
"(",
"$",
"appUUIDComposed",
",",
"$",
"indexUUIDComposed",
")",
"=",
"explode",
"(",
"'_'",
",",
"$",
"composed",
",",
"2",
"... | Create from composed.
@param string $composed
@return RepositoryReference | [
"Create",
"from",
"composed",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryReference.php#L128-L136 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.itemsToFormat | public function itemsToFormat(array $items): string
{
$this->checkDependencies();
$headers = [
'metadata' => [],
'indexed_metadata' => [],
'searchable_metadata' => [],
];
$data = [
'header' => &$headers,
];
$iteration =... | php | public function itemsToFormat(array $items): string
{
$this->checkDependencies();
$headers = [
'metadata' => [],
'indexed_metadata' => [],
'searchable_metadata' => [],
];
$data = [
'header' => &$headers,
];
$iteration =... | [
"public",
"function",
"itemsToFormat",
"(",
"array",
"$",
"items",
")",
":",
"string",
"{",
"$",
"this",
"->",
"checkDependencies",
"(",
")",
";",
"$",
"headers",
"=",
"[",
"'metadata'",
"=>",
"[",
"]",
",",
"'indexed_metadata'",
"=>",
"[",
"]",
",",
"... | Convert array of Items to string format.
This yaml format transforms each item into a plain and logic-less set of
data in order to be more comprehensive for the human eyes. To make this
happens, this format must work with some headers to define the
composition of the item hydration
fields:
metadata:
- field1
- field2... | [
"Convert",
"array",
"of",
"Items",
"to",
"string",
"format",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L74-L119 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.formatToItems | public function formatToItems(string $data): array
{
$this->checkDependencies();
$data = Yaml::parse($data);
$header = $data['header'];
unset($data['header']);
$items = [];
foreach ($data as $itemAsArray) {
$items[] = Item::createFromArray(
... | php | public function formatToItems(string $data): array
{
$this->checkDependencies();
$data = Yaml::parse($data);
$header = $data['header'];
unset($data['header']);
$items = [];
foreach ($data as $itemAsArray) {
$items[] = Item::createFromArray(
... | [
"public",
"function",
"formatToItems",
"(",
"string",
"$",
"data",
")",
":",
"array",
"{",
"$",
"this",
"->",
"checkDependencies",
"(",
")",
";",
"$",
"data",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"data",
")",
";",
"$",
"header",
"=",
"$",
"data",
... | Convert string formatted to array of Items.
@param string $data
@return Item[] | [
"Convert",
"string",
"formatted",
"to",
"array",
"of",
"Items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L128-L155 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.enrichHeadersWithItem | private function enrichHeadersWithItem(
array &$headers,
Item $item
) {
$this->enrichHeaderWithFields($headers, 'metadata', $item->getMetadata());
$this->enrichHeaderWithFields($headers, 'indexed_metadata', $item->getIndexedMetadata());
$this->enrichHeaderWithFields($headers,... | php | private function enrichHeadersWithItem(
array &$headers,
Item $item
) {
$this->enrichHeaderWithFields($headers, 'metadata', $item->getMetadata());
$this->enrichHeaderWithFields($headers, 'indexed_metadata', $item->getIndexedMetadata());
$this->enrichHeaderWithFields($headers,... | [
"private",
"function",
"enrichHeadersWithItem",
"(",
"array",
"&",
"$",
"headers",
",",
"Item",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"enrichHeaderWithFields",
"(",
"$",
"headers",
",",
"'metadata'",
",",
"$",
"item",
"->",
"getMetadata",
"(",
")",
")"... | Enrich headers list with an item.
@param array $headers
@param Item $item | [
"Enrich",
"headers",
"list",
"with",
"an",
"item",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L163-L170 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.enrichHeaderWithFields | private function enrichHeaderWithFields(
array &$headers,
string $section,
array $fields
) {
foreach ($fields as $fieldName => $_) {
if (!in_array($fieldName, $headers[$section])) {
$headers[$section][] = $fieldName;
}
}
} | php | private function enrichHeaderWithFields(
array &$headers,
string $section,
array $fields
) {
foreach ($fields as $fieldName => $_) {
if (!in_array($fieldName, $headers[$section])) {
$headers[$section][] = $fieldName;
}
}
} | [
"private",
"function",
"enrichHeaderWithFields",
"(",
"array",
"&",
"$",
"headers",
",",
"string",
"$",
"section",
",",
"array",
"$",
"fields",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"_",
")",
"{",
"if",
"(",
"!",
... | Enrich headers list with an item.
@param array $headers
@param string $section
@param array $fields | [
"Enrich",
"headers",
"list",
"with",
"an",
"item",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L179-L189 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.parseFieldsFromHeaderAndItemAsArray | private function parseFieldsFromHeaderAndItemAsArray(
array $header,
array $item
) {
return [
'metadata' => $this->parseSectionFromHeaderAndItemAsArray($header, 'metadata', $item),
'indexed_metadata' => $this->parseSectionFromHeaderAndItemAsArray($header, 'indexed_met... | php | private function parseFieldsFromHeaderAndItemAsArray(
array $header,
array $item
) {
return [
'metadata' => $this->parseSectionFromHeaderAndItemAsArray($header, 'metadata', $item),
'indexed_metadata' => $this->parseSectionFromHeaderAndItemAsArray($header, 'indexed_met... | [
"private",
"function",
"parseFieldsFromHeaderAndItemAsArray",
"(",
"array",
"$",
"header",
",",
"array",
"$",
"item",
")",
"{",
"return",
"[",
"'metadata'",
"=>",
"$",
"this",
"->",
"parseSectionFromHeaderAndItemAsArray",
"(",
"$",
"header",
",",
"'metadata'",
","... | Parse fields from item having header.
@param array $header
@param array $item
@return array | [
"Parse",
"fields",
"from",
"item",
"having",
"header",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L199-L208 |
apisearch-io/php-client | Exporter/YamlExporter.php | YamlExporter.parseSectionFromHeaderAndItemAsArray | private function parseSectionFromHeaderAndItemAsArray(
array $header,
string $section,
array $item
) {
return array_intersect_key(
$item,
array_flip($header[$section] ?? [])
);
} | php | private function parseSectionFromHeaderAndItemAsArray(
array $header,
string $section,
array $item
) {
return array_intersect_key(
$item,
array_flip($header[$section] ?? [])
);
} | [
"private",
"function",
"parseSectionFromHeaderAndItemAsArray",
"(",
"array",
"$",
"header",
",",
"string",
"$",
"section",
",",
"array",
"$",
"item",
")",
"{",
"return",
"array_intersect_key",
"(",
"$",
"item",
",",
"array_flip",
"(",
"$",
"header",
"[",
"$",
... | Parse section fields from item having header.
@param array $header
@param string $section
@param array $item
@return array | [
"Parse",
"section",
"fields",
"from",
"item",
"having",
"header",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/YamlExporter.php#L219-L228 |
apisearch-io/php-client | Result/Result.php | Result.create | public static function create(
?string $queryUUID,
int $totalItems,
int $totalHits,
? Aggregations $aggregations,
array $suggests,
array $items
): self {
$result = new self(
$queryUUID,
$totalItems,
$totalHits
);
... | php | public static function create(
?string $queryUUID,
int $totalItems,
int $totalHits,
? Aggregations $aggregations,
array $suggests,
array $items
): self {
$result = new self(
$queryUUID,
$totalItems,
$totalHits
);
... | [
"public",
"static",
"function",
"create",
"(",
"?",
"string",
"$",
"queryUUID",
",",
"int",
"$",
"totalItems",
",",
"int",
"$",
"totalHits",
",",
"?",
"Aggregations",
"$",
"aggregations",
",",
"array",
"$",
"suggests",
",",
"array",
"$",
"items",
")",
":... | Create by.
@param string|null $queryUUID
@param int $totalItems
@param int $totalHits
@param Aggregations|null $aggregations
@param string[] $suggests
@param Item[] $items
@return Result | [
"Create",
"by",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L111-L130 |
apisearch-io/php-client | Result/Result.php | Result.getItemsGroupedByTypes | public function getItemsGroupedByTypes(): array
{
if (is_array($this->itemsGroupedByTypeCache)) {
return $this->itemsGroupedByTypeCache;
}
$items = $this->getItems();
$itemsGroupedByType = [];
foreach ($items as $item) {
if (!isset($itemsGroupedByType... | php | public function getItemsGroupedByTypes(): array
{
if (is_array($this->itemsGroupedByTypeCache)) {
return $this->itemsGroupedByTypeCache;
}
$items = $this->getItems();
$itemsGroupedByType = [];
foreach ($items as $item) {
if (!isset($itemsGroupedByType... | [
"public",
"function",
"getItemsGroupedByTypes",
"(",
")",
":",
"array",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"itemsGroupedByTypeCache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"itemsGroupedByTypeCache",
";",
"}",
"$",
"items",
"=",
"$",
... | Get items grouped by type.
@return array | [
"Get",
"items",
"grouped",
"by",
"type",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L172-L190 |
apisearch-io/php-client | Result/Result.php | Result.getItemsByTypes | public function getItemsByTypes(array $types): array
{
return array_filter(
$this->getItems(),
function (Item $item) use ($types) {
return in_array(
$item->getType(),
$types
);
}
);
} | php | public function getItemsByTypes(array $types): array
{
return array_filter(
$this->getItems(),
function (Item $item) use ($types) {
return in_array(
$item->getType(),
$types
);
}
);
} | [
"public",
"function",
"getItemsByTypes",
"(",
"array",
"$",
"types",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"getItems",
"(",
")",
",",
"function",
"(",
"Item",
"$",
"item",
")",
"use",
"(",
"$",
"types",
")",
"{",
"... | Get Items by a certain types.
@param array $types
@return Item[] | [
"Get",
"Items",
"by",
"a",
"certain",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L211-L222 |
apisearch-io/php-client | Result/Result.php | Result.getFirstItem | public function getFirstItem()
{
$results = $this->getItems();
if (empty($results)) {
return null;
}
$firstItem = reset($results);
return $firstItem;
} | php | public function getFirstItem()
{
$results = $this->getItems();
if (empty($results)) {
return null;
}
$firstItem = reset($results);
return $firstItem;
} | [
"public",
"function",
"getFirstItem",
"(",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getItems",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"results",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"firstItem",
"=",
"reset",
"(",
"$",
... | Get first result.
@return Item|null | [
"Get",
"first",
"result",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L229-L240 |
apisearch-io/php-client | Result/Result.php | Result.getAggregation | public function getAggregation(string $name): ? Aggregation
{
if (is_null($this->aggregations)) {
return null;
}
return $this
->aggregations
->getAggregation($name);
} | php | public function getAggregation(string $name): ? Aggregation
{
if (is_null($this->aggregations)) {
return null;
}
return $this
->aggregations
->getAggregation($name);
} | [
"public",
"function",
"getAggregation",
"(",
"string",
"$",
"name",
")",
":",
"?",
"Aggregation",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"aggregations",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"aggregations",
... | Get aggregation.
@param string $name
@return Aggregation|null | [
"Get",
"aggregation",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L269-L278 |
apisearch-io/php-client | Result/Result.php | Result.hasNotEmptyAggregation | public function hasNotEmptyAggregation(string $name): bool
{
if (is_null($this->aggregations)) {
return false;
}
return $this
->aggregations
->hasNotEmptyAggregation($name);
} | php | public function hasNotEmptyAggregation(string $name): bool
{
if (is_null($this->aggregations)) {
return false;
}
return $this
->aggregations
->hasNotEmptyAggregation($name);
} | [
"public",
"function",
"hasNotEmptyAggregation",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"aggregations",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"aggregations",
"->"... | Has not empty aggregation.
@param string $name
@return bool | [
"Has",
"not",
"empty",
"aggregation",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L287-L296 |
apisearch-io/php-client | Result/Result.php | Result.toArray | public function toArray(): array
{
return array_filter([
'query_uuid' => $this->queryUUID,
'total_items' => $this->totalItems,
'total_hits' => $this->totalHits,
'items' => array_map(function (Item $item) {
return $item->toArray();
}... | php | public function toArray(): array
{
return array_filter([
'query_uuid' => $this->queryUUID,
'total_items' => $this->totalItems,
'total_hits' => $this->totalHits,
'items' => array_map(function (Item $item) {
return $item->toArray();
}... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'query_uuid'",
"=>",
"$",
"this",
"->",
"queryUUID",
",",
"'total_items'",
"=>",
"$",
"this",
"->",
"totalItems",
",",
"'total_hits'",
"=>",
"$",
"this",
"->... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L363-L386 |
apisearch-io/php-client | Result/Result.php | Result.createFromArray | public static function createFromArray(array $array): self
{
$result = self::create(
$array['query_uuid'] ?? '',
$array['total_items'] ?? 0,
$array['total_hits'] ?? 0,
isset($array['aggregations'])
? Aggregations::createFromArray($array['aggreg... | php | public static function createFromArray(array $array): self
{
$result = self::create(
$array['query_uuid'] ?? '',
$array['total_items'] ?? 0,
$array['total_hits'] ?? 0,
isset($array['aggregations'])
? Aggregations::createFromArray($array['aggreg... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"$",
"result",
"=",
"self",
"::",
"create",
"(",
"$",
"array",
"[",
"'query_uuid'",
"]",
"??",
"''",
",",
"$",
"array",
"[",
"'total_items'",
"]",
"??... | Create from array.
@param array $array
@return Result | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Result.php#L395-L417 |
apisearch-io/php-client | User/UserRepositoryBucket.php | UserRepositoryBucket.findRepository | public function findRepository(string $name): ? UserRepository
{
return isset($this->repositories[$name])
? $this->repositories[$name]
: null;
} | php | public function findRepository(string $name): ? UserRepository
{
return isset($this->repositories[$name])
? $this->repositories[$name]
: null;
} | [
"public",
"function",
"findRepository",
"(",
"string",
"$",
"name",
")",
":",
"?",
"UserRepository",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"repositories",
"[",
"$",
"name",
"... | Get repository by name and index.
@param string $name
@return UserRepository|null | [
"Get",
"repository",
"by",
"name",
"and",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/User/UserRepositoryBucket.php#L50-L55 |
apisearch-io/php-client | Config/SynonymReader.php | SynonymReader.readSynonymsFromFile | public function readSynonymsFromFile(string $filepath): array
{
if (
!is_file($filepath) ||
!is_readable($filepath)
) {
throw SynonymsException::synonymsFileNotFound($filepath);
}
$data = file_get_contents($filepath);
if (!is_string($data... | php | public function readSynonymsFromFile(string $filepath): array
{
if (
!is_file($filepath) ||
!is_readable($filepath)
) {
throw SynonymsException::synonymsFileNotFound($filepath);
}
$data = file_get_contents($filepath);
if (!is_string($data... | [
"public",
"function",
"readSynonymsFromFile",
"(",
"string",
"$",
"filepath",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filepath",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filepath",
")",
")",
"{",
"throw",
"SynonymsException",
"::",
... | Read synonyms from file.
@param string $filepath
@return Synonym[]
@throws SynonymsException | [
"Read",
"synonyms",
"from",
"file",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Config/SynonymReader.php#L34-L62 |
apisearch-io/php-client | Config/SynonymReader.php | SynonymReader.readSynonymsFromCommaSeparatedArray | public function readSynonymsFromCommaSeparatedArray(array $synonymsAsCommaSeparatedArray): array
{
return array_filter(array_map(function (string $line) {
if (empty($line)) {
return false;
}
$words = explode(',', $line);
if (count($words) <= ... | php | public function readSynonymsFromCommaSeparatedArray(array $synonymsAsCommaSeparatedArray): array
{
return array_filter(array_map(function (string $line) {
if (empty($line)) {
return false;
}
$words = explode(',', $line);
if (count($words) <= ... | [
"public",
"function",
"readSynonymsFromCommaSeparatedArray",
"(",
"array",
"$",
"synonymsAsCommaSeparatedArray",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"array_map",
"(",
"function",
"(",
"string",
"$",
"line",
")",
"{",
"if",
"(",
"empty",
"(",
"... | Read synonyms from comma separated array.
@param array $synonymsAsCommaSeparatedArray
@return Synonym[] | [
"Read",
"synonyms",
"from",
"comma",
"separated",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Config/SynonymReader.php#L71-L86 |
apisearch-io/php-client | Repository/DiskRepository.php | DiskRepository.query | public function query(
Query $query,
array $parameters = []
): Result {
$this->load();
return parent::query($query);
} | php | public function query(
Query $query,
array $parameters = []
): Result {
$this->load();
return parent::query($query);
} | [
"public",
"function",
"query",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
":",
"Result",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"return",
"parent",
"::",
"query",
"(",
"$",
"query",
")",
";",
"}"
] | Search across the index types.
@param Query $query
@param array $parameters
@return Result | [
"Search",
"across",
"the",
"index",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/DiskRepository.php#L54-L61 |
apisearch-io/php-client | Repository/DiskRepository.php | DiskRepository.flushItems | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
$this->load();
parent::flushItems(
$itemsToUpdate,
$itemsToDelete
);
$this->save();
} | php | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
$this->load();
parent::flushItems(
$itemsToUpdate,
$itemsToDelete
);
$this->save();
} | [
"protected",
"function",
"flushItems",
"(",
"array",
"$",
"itemsToUpdate",
",",
"array",
"$",
"itemsToDelete",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"flushItems",
"(",
"$",
"itemsToUpdate",
",",
"$",
"itemsToDelete",
")",
";",... | Flush items.
@param Item[] $itemsToUpdate
@param ItemUUID[] $itemsToDelete | [
"Flush",
"items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/DiskRepository.php#L81-L91 |
apisearch-io/php-client | Repository/DiskRepository.php | DiskRepository.load | private function load()
{
if (!file_exists($this->filename)) {
return;
}
$this->items = unserialize(
file_get_contents(
$this->filename
)
) ?? [];
} | php | private function load()
{
if (!file_exists($this->filename)) {
return;
}
$this->items = unserialize(
file_get_contents(
$this->filename
)
) ?? [];
} | [
"private",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"items",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"fil... | Load. | [
"Load",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/DiskRepository.php#L96-L107 |
apisearch-io/php-client | Repository/HttpRepository.php | HttpRepository.flushItems | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
if (!empty($itemsToUpdate)) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/items',
$... | php | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
if (!empty($itemsToUpdate)) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/items',
$... | [
"protected",
"function",
"flushItems",
"(",
"array",
"$",
"itemsToUpdate",
",",
"array",
"$",
"itemsToDelete",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"itemsToUpdate",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get"... | Flush items.
@param Item[] $itemsToUpdate
@param ItemUUID[] $itemsToDelete | [
"Flush",
"items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/HttpRepository.php#L59-L102 |
apisearch-io/php-client | Repository/HttpRepository.php | HttpRepository.updateItems | public function updateItems(
Query $query,
Changes $changes
) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/items/update-by-query',
$this->getAppUUID()->composeUUID(),
$this... | php | public function updateItems(
Query $query,
Changes $changes
) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/items/update-by-query',
$this->getAppUUID()->composeUUID(),
$this... | [
"public",
"function",
"updateItems",
"(",
"Query",
"$",
"query",
",",
"Changes",
"$",
"changes",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices/%s/items/update-by-query'",
",",
"$",
"this",
"-... | Update items.
@param Query $query
@param Changes $changes | [
"Update",
"items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/HttpRepository.php#L110-L132 |
apisearch-io/php-client | Repository/HttpRepository.php | HttpRepository.query | public function query(
Query $query,
array $parameters = []
): Result {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$this->getIndexUUID... | php | public function query(
Query $query,
array $parameters = []
): Result {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$this->getIndexUUID... | [
"public",
"function",
"query",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
":",
"Result",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices/%s'",
",",
"$",
... | Search across the index types.
@param Query $query
@param array $parameters
@return Result | [
"Search",
"across",
"the",
"index",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/HttpRepository.php#L142-L165 |
apisearch-io/php-client | Query/Aggregation.php | Aggregation.create | public static function create(
string $name,
string $field,
int $applicationType,
string $filterType,
array $subgroup = [],
array $sort = self::SORT_BY_COUNT_DESC,
int $limit = self::NO_LIMIT
): self {
return new self(
$name,
$f... | php | public static function create(
string $name,
string $field,
int $applicationType,
string $filterType,
array $subgroup = [],
array $sort = self::SORT_BY_COUNT_DESC,
int $limit = self::NO_LIMIT
): self {
return new self(
$name,
$f... | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"field",
",",
"int",
"$",
"applicationType",
",",
"string",
"$",
"filterType",
",",
"array",
"$",
"subgroup",
"=",
"[",
"]",
",",
"array",
"$",
"sort",
"=",
"self... | Create.
@param string $name
@param string $field
@param int $applicationType
@param string $filterType
@param array $subgroup
@param array $sort
@param int $limit
@return Aggregation | [
"Create",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Aggregation.php#L222-L240 |
apisearch-io/php-client | Query/Aggregation.php | Aggregation.toArray | public function toArray(): array
{
return array_filter([
'name' => $this->name,
'field' => 'uuid.type' === $this->field
? null
: $this->field,
'application_type' => Filter::AT_LEAST_ONE === $this->applicationType
? null
... | php | public function toArray(): array
{
return array_filter([
'name' => $this->name,
'field' => 'uuid.type' === $this->field
? null
: $this->field,
'application_type' => Filter::AT_LEAST_ONE === $this->applicationType
? null
... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'field'",
"=>",
"'uuid.type'",
"===",
"$",
"this",
"->",
"field",
"?",
"null",
":",
"$",
"this",
"->",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Aggregation.php#L247-L276 |
apisearch-io/php-client | Query/Aggregation.php | Aggregation.createFromArray | public static function createFromArray(array $array): self
{
if (empty($array['name'])) {
throw InvalidFormatException::queryFormatNotValid($array);
}
return self::create(
$array['name'],
$array['field'] ?? 'uuid.type',
(int) ($array['applicat... | php | public static function createFromArray(array $array): self
{
if (empty($array['name'])) {
throw InvalidFormatException::queryFormatNotValid($array);
}
return self::create(
$array['name'],
$array['field'] ?? 'uuid.type',
(int) ($array['applicat... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"if",
"(",
"empty",
"(",
"$",
"array",
"[",
"'name'",
"]",
")",
")",
"{",
"throw",
"InvalidFormatException",
"::",
"queryFormatNotValid",
"(",
"$",
"array... | Create from array.
@param array $array
@return Aggregation | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Aggregation.php#L285-L300 |
apisearch-io/php-client | App/AppRepositoryBucket.php | AppRepositoryBucket.findRepository | public function findRepository(string $appName): ? AppRepository
{
return isset($this->repositories[$appName])
? $this->repositories[$appName]
: null;
} | php | public function findRepository(string $appName): ? AppRepository
{
return isset($this->repositories[$appName])
? $this->repositories[$appName]
: null;
} | [
"public",
"function",
"findRepository",
"(",
"string",
"$",
"appName",
")",
":",
"?",
"AppRepository",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"appName",
"]",
")",
"?",
"$",
"this",
"->",
"repositories",
"[",
"$",
"appNa... | Get repository by name and index.
@param string $appName
@return AppRepository|null | [
"Get",
"repository",
"by",
"name",
"and",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/AppRepositoryBucket.php#L67-L72 |
apisearch-io/php-client | Model/Index.php | Index.toArray | public function toArray(): array
{
return [
'uuid' => $this->uuid->toArray(),
'app_id' => $this->appUUID->toArray(),
'is_ok' => $this->isOK,
'doc_count' => $this->docCount,
'size' => $this->size,
'shards' => $this->shards,
'... | php | public function toArray(): array
{
return [
'uuid' => $this->uuid->toArray(),
'app_id' => $this->appUUID->toArray(),
'is_ok' => $this->isOK,
'doc_count' => $this->docCount,
'size' => $this->size,
'shards' => $this->shards,
'... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'uuid'",
"=>",
"$",
"this",
"->",
"uuid",
"->",
"toArray",
"(",
")",
",",
"'app_id'",
"=>",
"$",
"this",
"->",
"appUUID",
"->",
"toArray",
"(",
")",
",",
"'is_ok'",
"=>",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Index.php#L217-L230 |
apisearch-io/php-client | Model/Index.php | Index.createFromArray | public static function createFromArray(array $array): self
{
if (!isset($array['uuid'], $array['app_id'])) {
throw InvalidFormatException::indexFormatNotValid();
}
return new self(
IndexUUID::createFromArray($array['uuid']),
AppUUID::createFromArray($arra... | php | public static function createFromArray(array $array): self
{
if (!isset($array['uuid'], $array['app_id'])) {
throw InvalidFormatException::indexFormatNotValid();
}
return new self(
IndexUUID::createFromArray($array['uuid']),
AppUUID::createFromArray($arra... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"'uuid'",
"]",
",",
"$",
"array",
"[",
"'app_id'",
"]",
")",
")",
"{",
"throw",
"InvalidFormatExcepti... | Create from array.
@param array $array
@return Index
@throws InvalidFormatException | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Index.php#L241-L258 |
apisearch-io/php-client | Exporter/IndexExporter.php | IndexExporter.importIndex | public function importIndex(
Repository $repository,
string $data,
string $format
) {
$items = $this
->exporterCollection
->getExporterByName($format)
->formatToItems($data);
$repository->addItems($items);
$repository->flush();
... | php | public function importIndex(
Repository $repository,
string $data,
string $format
) {
$items = $this
->exporterCollection
->getExporterByName($format)
->formatToItems($data);
$repository->addItems($items);
$repository->flush();
... | [
"public",
"function",
"importIndex",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"data",
",",
"string",
"$",
"format",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"exporterCollection",
"->",
"getExporterByName",
"(",
"$",
"format",
")",
"... | Import index.
@param Repository $repository
@param string $data
@param string $format | [
"Import",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/IndexExporter.php#L50-L62 |
apisearch-io/php-client | Exporter/IndexExporter.php | IndexExporter.exportIndex | public function exportIndex(
Repository $repository,
string $format
): string {
$allItems = [];
$iteration = 0;
while (true) {
$items = $repository
->query(Query::create('', $iteration, 10000))
->getItems();
if (empty($... | php | public function exportIndex(
Repository $repository,
string $format
): string {
$allItems = [];
$iteration = 0;
while (true) {
$items = $repository
->query(Query::create('', $iteration, 10000))
->getItems();
if (empty($... | [
"public",
"function",
"exportIndex",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"format",
")",
":",
"string",
"{",
"$",
"allItems",
"=",
"[",
"]",
";",
"$",
"iteration",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"$",
"items",
"=",... | Export index.
@param Repository $repository
@param string $format
@return string | [
"Export",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exporter/IndexExporter.php#L72-L99 |
apisearch-io/php-client | Config/Config.php | Config.toArray | public function toArray(): array
{
return array_filter([
'language' => $this->language,
'store_searchable_metadata' => ($this->storeSearchableMetadata ? null : false),
'synonyms' => array_map(function (Synonym $synonym) {
return $synonym->toArray();
... | php | public function toArray(): array
{
return array_filter([
'language' => $this->language,
'store_searchable_metadata' => ($this->storeSearchableMetadata ? null : false),
'synonyms' => array_map(function (Synonym $synonym) {
return $synonym->toArray();
... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'language'",
"=>",
"$",
"this",
"->",
"language",
",",
"'store_searchable_metadata'",
"=>",
"(",
"$",
"this",
"->",
"storeSearchableMetadata",
"?",
"null",
":",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Config/Config.php#L163-L180 |
apisearch-io/php-client | Config/Config.php | Config.createFromArray | public static function createFromArray(array $array): self
{
$config = new self(
($array['language'] ?? null),
($array['store_searchable_metadata'] ?? true)
);
$config->synonyms = array_map(function (array $synonym) {
return Synonym::createFromArray($syno... | php | public static function createFromArray(array $array): self
{
$config = new self(
($array['language'] ?? null),
($array['store_searchable_metadata'] ?? true)
);
$config->synonyms = array_map(function (array $synonym) {
return Synonym::createFromArray($syno... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"$",
"config",
"=",
"new",
"self",
"(",
"(",
"$",
"array",
"[",
"'language'",
"]",
"??",
"null",
")",
",",
"(",
"$",
"array",
"[",
"'store_searchable_... | Create from array.
@param array $array
@return self | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Config/Config.php#L189-L203 |
apisearch-io/php-client | Query/Query.php | Query.createLocated | public static function createLocated(
Coordinate $coordinate,
string $queryText,
int $page = self::DEFAULT_PAGE,
int $size = self::DEFAULT_SIZE
) {
$query = self::create(
$queryText,
$page,
$size
);
$query->coordinate = $co... | php | public static function createLocated(
Coordinate $coordinate,
string $queryText,
int $page = self::DEFAULT_PAGE,
int $size = self::DEFAULT_SIZE
) {
$query = self::create(
$queryText,
$page,
$size
);
$query->coordinate = $co... | [
"public",
"static",
"function",
"createLocated",
"(",
"Coordinate",
"$",
"coordinate",
",",
"string",
"$",
"queryText",
",",
"int",
"$",
"page",
"=",
"self",
"::",
"DEFAULT_PAGE",
",",
"int",
"$",
"size",
"=",
"self",
"::",
"DEFAULT_SIZE",
")",
"{",
"$",
... | Create located Query.
@param Coordinate $coordinate
@param string $queryText
@param int $page
@param int $size
@return Query | [
"Create",
"located",
"Query",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L247-L262 |
apisearch-io/php-client | Query/Query.php | Query.create | public static function create(
string $queryText,
int $page = self::DEFAULT_PAGE,
int $size = self::DEFAULT_SIZE
): self {
$page = (int) (max(1, $page));
$query = new self($queryText);
$query->from = ($page - 1) * $size;
$query->size = $size;
$query->p... | php | public static function create(
string $queryText,
int $page = self::DEFAULT_PAGE,
int $size = self::DEFAULT_SIZE
): self {
$page = (int) (max(1, $page));
$query = new self($queryText);
$query->from = ($page - 1) * $size;
$query->size = $size;
$query->p... | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"queryText",
",",
"int",
"$",
"page",
"=",
"self",
"::",
"DEFAULT_PAGE",
",",
"int",
"$",
"size",
"=",
"self",
"::",
"DEFAULT_SIZE",
")",
":",
"self",
"{",
"$",
"page",
"=",
"(",
"int",
")... | Create new.
@param string $queryText
@param int $page
@param int $size
@return Query | [
"Create",
"new",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L273-L285 |
apisearch-io/php-client | Query/Query.php | Query.createByUUIDs | public static function createByUUIDs(array $uuids): self
{
$ids = array_map(function (ItemUUID $uuid) {
return $uuid->composeUUID();
}, $uuids);
$query = self::create('', self::DEFAULT_PAGE, count($uuids))
->disableAggregations()
->disableSuggestions();
... | php | public static function createByUUIDs(array $uuids): self
{
$ids = array_map(function (ItemUUID $uuid) {
return $uuid->composeUUID();
}, $uuids);
$query = self::create('', self::DEFAULT_PAGE, count($uuids))
->disableAggregations()
->disableSuggestions();
... | [
"public",
"static",
"function",
"createByUUIDs",
"(",
"array",
"$",
"uuids",
")",
":",
"self",
"{",
"$",
"ids",
"=",
"array_map",
"(",
"function",
"(",
"ItemUUID",
"$",
"uuid",
")",
"{",
"return",
"$",
"uuid",
"->",
"composeUUID",
"(",
")",
";",
"}",
... | Create by references.
@param ItemUUID[] $uuids
@return Query | [
"Create",
"by",
"references",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L320-L338 |
apisearch-io/php-client | Query/Query.php | Query.filterUniverseByTypes | public function filterUniverseByTypes(array $values): self
{
$fieldPath = Item::getPathByField('type');
if (!empty($values)) {
$this->universeFilters['type'] = Filter::create(
$fieldPath,
$values,
Filter::AT_LEAST_ONE,
Filte... | php | public function filterUniverseByTypes(array $values): self
{
$fieldPath = Item::getPathByField('type');
if (!empty($values)) {
$this->universeFilters['type'] = Filter::create(
$fieldPath,
$values,
Filter::AT_LEAST_ONE,
Filte... | [
"public",
"function",
"filterUniverseByTypes",
"(",
"array",
"$",
"values",
")",
":",
"self",
"{",
"$",
"fieldPath",
"=",
"Item",
"::",
"getPathByField",
"(",
"'type'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"this",
... | Filter universe by types.
@param array $values
@return Query | [
"Filter",
"universe",
"by",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L386-L401 |
apisearch-io/php-client | Query/Query.php | Query.filterByTypes | public function filterByTypes(
array $values,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
$fieldPath = Item::getPathByField('type');
if (!empty($values)) {
$this->filters['type'] = Filter::create(
$fie... | php | public function filterByTypes(
array $values,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
$fieldPath = Item::getPathByField('type');
if (!empty($values)) {
$this->filters['type'] = Filter::create(
$fie... | [
"public",
"function",
"filterByTypes",
"(",
"array",
"$",
"values",
",",
"bool",
"$",
"aggregate",
"=",
"true",
",",
"array",
"$",
"aggregationSort",
"=",
"Aggregation",
"::",
"SORT_BY_COUNT_DESC",
")",
":",
"self",
"{",
"$",
"fieldPath",
"=",
"Item",
"::",
... | Filter by types.
@param array $values
@param bool $aggregate
@param array $aggregationSort
@return Query | [
"Filter",
"by",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L412-L441 |
apisearch-io/php-client | Query/Query.php | Query.filterByIds | public function filterByIds(array $values): self
{
$fieldPath = Item::getPathByField('id');
if (!empty($values)) {
$this->filters['id'] = Filter::create(
$fieldPath,
$values,
Filter::AT_LEAST_ONE,
Filter::TYPE_FIELD
... | php | public function filterByIds(array $values): self
{
$fieldPath = Item::getPathByField('id');
if (!empty($values)) {
$this->filters['id'] = Filter::create(
$fieldPath,
$values,
Filter::AT_LEAST_ONE,
Filter::TYPE_FIELD
... | [
"public",
"function",
"filterByIds",
"(",
"array",
"$",
"values",
")",
":",
"self",
"{",
"$",
"fieldPath",
"=",
"Item",
"::",
"getPathByField",
"(",
"'id'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"this",
"->",
"f... | Filter by types.
@param array $values
@return Query | [
"Filter",
"by",
"types",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L474-L489 |
apisearch-io/php-client | Query/Query.php | Query.filterUniverseBy | public function filterUniverseBy(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE
): self {
$fieldPath = Item::getPathByField($field);
if (!empty($values)) {
$this->universeFilters[$field] = Filter::create(
$fieldPath,
... | php | public function filterUniverseBy(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE
): self {
$fieldPath = Item::getPathByField($field);
if (!empty($values)) {
$this->universeFilters[$field] = Filter::create(
$fieldPath,
... | [
"public",
"function",
"filterUniverseBy",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
")",
":",
"self",
"{",
"$",
"fieldPath",
"=",
"Item",
"::",
"getPathByField",
"(",
... | Filter universe by.
@param string $field
@param array $values
@param int $applicationType
@return Query | [
"Filter",
"universe",
"by",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L500-L518 |
apisearch-io/php-client | Query/Query.php | Query.filterBy | public function filterBy(
string $filterName,
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
$fieldPath = Item::getPathByField($field);
... | php | public function filterBy(
string $filterName,
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
$fieldPath = Item::getPathByField($field);
... | [
"public",
"function",
"filterBy",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
",",
"bool",
"$",
"aggregate",
"=",
"true",
",",
"array",... | Filter by.
@param string $filterName
@param string $field
@param array $values
@param int $applicationType
@param bool $aggregate
@param array $aggregationSort
@return Query | [
"Filter",
"by",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L532-L562 |
apisearch-io/php-client | Query/Query.php | Query.filterUniverseByRange | public function filterUniverseByRange(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
string $rangeType = Filter::TYPE_RANGE
): self {
$fieldPath = Item::getPathByField($field);
if (!empty($values)) {
$this->universeFilters[$fie... | php | public function filterUniverseByRange(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
string $rangeType = Filter::TYPE_RANGE
): self {
$fieldPath = Item::getPathByField($field);
if (!empty($values)) {
$this->universeFilters[$fie... | [
"public",
"function",
"filterUniverseByRange",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
",",
"string",
"$",
"rangeType",
"=",
"Filter",
"::",
"TYPE_RANGE",
")",
":",
"s... | Filter universe by range.
@param string $field
@param array $values
@param int $applicationType
@param string $rangeType
@return Query | [
"Filter",
"universe",
"by",
"range",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L574-L593 |
apisearch-io/php-client | Query/Query.php | Query.filterUniverseByDateRange | public function filterUniverseByDateRange(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE
): self {
return $this->filterUniverseByRange(
$field,
$values,
$applicationType,
Filter::TYPE_DATE_RANGE
);
... | php | public function filterUniverseByDateRange(
string $field,
array $values,
int $applicationType = Filter::AT_LEAST_ONE
): self {
return $this->filterUniverseByRange(
$field,
$values,
$applicationType,
Filter::TYPE_DATE_RANGE
);
... | [
"public",
"function",
"filterUniverseByDateRange",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"filterUniverseByRange",
"... | Filter universe by range.
@param string $field
@param array $values
@param int $applicationType
@return Query | [
"Filter",
"universe",
"by",
"range",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L604-L615 |
apisearch-io/php-client | Query/Query.php | Query.filterByRange | public function filterByRange(
string $filterName,
string $field,
array $options,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
string $rangeType = Filter::TYPE_RANGE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUN... | php | public function filterByRange(
string $filterName,
string $field,
array $options,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
string $rangeType = Filter::TYPE_RANGE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUN... | [
"public",
"function",
"filterByRange",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
",",
"string",
"$",
"r... | Filter by range.
@param string $filterName
@param string $field
@param array $options
@param array $values
@param int $applicationType
@param string $rangeType
@param bool $aggregate
@param array $aggregationSort
@return Query | [
"Filter",
"by",
"range",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L631-L665 |
apisearch-io/php-client | Query/Query.php | Query.filterByDateRange | public function filterByDateRange(
string $filterName,
string $field,
array $options,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
return $this->f... | php | public function filterByDateRange(
string $filterName,
string $field,
array $options,
array $values,
int $applicationType = Filter::AT_LEAST_ONE,
bool $aggregate = true,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC
): self {
return $this->f... | [
"public",
"function",
"filterByDateRange",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
"=",
"Filter",
"::",
"AT_LEAST_ONE",
",",
"bool",
"$",
... | Filter by range.
@param string $filterName
@param string $field
@param array $options
@param array $values
@param int $applicationType
@param bool $aggregate
@param array $aggregationSort
@return Query | [
"Filter",
"by",
"range",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L680-L699 |
apisearch-io/php-client | Query/Query.php | Query.filterUniverseByLocation | public function filterUniverseByLocation(LocationRange $locationRange): self
{
$this->universeFilters['coordinate'] = Filter::create(
'coordinate',
$locationRange->toArray(),
Filter::AT_LEAST_ONE,
Filter::TYPE_GEO
);
return $this;
} | php | public function filterUniverseByLocation(LocationRange $locationRange): self
{
$this->universeFilters['coordinate'] = Filter::create(
'coordinate',
$locationRange->toArray(),
Filter::AT_LEAST_ONE,
Filter::TYPE_GEO
);
return $this;
} | [
"public",
"function",
"filterUniverseByLocation",
"(",
"LocationRange",
"$",
"locationRange",
")",
":",
"self",
"{",
"$",
"this",
"->",
"universeFilters",
"[",
"'coordinate'",
"]",
"=",
"Filter",
"::",
"create",
"(",
"'coordinate'",
",",
"$",
"locationRange",
"-... | Filter universe by location.
@param LocationRange $locationRange
@return Query | [
"Filter",
"universe",
"by",
"location",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L708-L718 |
apisearch-io/php-client | Query/Query.php | Query.sortBy | public function sortBy(SortBy $sortBy): self
{
if ($sortBy->isSortedByGeoDistance()) {
if (!$this->coordinate instanceof Coordinate) {
throw InvalidFormatException::querySortedByDistanceWithoutCoordinate();
}
$sortBy->setCoordinate($this->coordinate);
... | php | public function sortBy(SortBy $sortBy): self
{
if ($sortBy->isSortedByGeoDistance()) {
if (!$this->coordinate instanceof Coordinate) {
throw InvalidFormatException::querySortedByDistanceWithoutCoordinate();
}
$sortBy->setCoordinate($this->coordinate);
... | [
"public",
"function",
"sortBy",
"(",
"SortBy",
"$",
"sortBy",
")",
":",
"self",
"{",
"if",
"(",
"$",
"sortBy",
"->",
"isSortedByGeoDistance",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"coordinate",
"instanceof",
"Coordinate",
")",
"{",
"th... | Sort by.
@param SortBy $sortBy
@return Query | [
"Sort",
"by",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L751-L764 |
apisearch-io/php-client | Query/Query.php | Query.aggregateBy | public function aggregateBy(
string $filterName,
string $field,
int $applicationType,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
$this->aggregations[$filterName] = Aggregation::create(
$filterName... | php | public function aggregateBy(
string $filterName,
string $field,
int $applicationType,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
$this->aggregations[$filterName] = Aggregation::create(
$filterName... | [
"public",
"function",
"aggregateBy",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"int",
"$",
"applicationType",
",",
"array",
"$",
"aggregationSort",
"=",
"Aggregation",
"::",
"SORT_BY_COUNT_DESC",
",",
"int",
"$",
"limit",
"=",
"Aggreg... | Add Families aggregation.
@param string $filterName
@param string $field
@param int $applicationType
@param array $aggregationSort
@param int $limit
@return Query | [
"Add",
"Families",
"aggregation",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L777-L795 |
apisearch-io/php-client | Query/Query.php | Query.aggregateByRange | public function aggregateByRange(
string $filterName,
string $field,
array $options,
int $applicationType,
string $rangeType = Filter::TYPE_RANGE,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
if... | php | public function aggregateByRange(
string $filterName,
string $field,
array $options,
int $applicationType,
string $rangeType = Filter::TYPE_RANGE,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
if... | [
"public",
"function",
"aggregateByRange",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
",",
"int",
"$",
"applicationType",
",",
"string",
"$",
"rangeType",
"=",
"Filter",
"::",
"TYPE_RANGE",
",",
"array",
"$",
... | Add tags aggregation.
@param string $filterName
@param string $field
@param array $options
@param int $applicationType
@param string $rangeType
@param array $aggregationSort
@param int $limit
@return Query | [
"Add",
"tags",
"aggregation",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L810-L834 |
apisearch-io/php-client | Query/Query.php | Query.aggregateByDateRange | public function aggregateByDateRange(
string $filterName,
string $field,
array $options,
int $applicationType,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
if (empty($options)) {
return $thi... | php | public function aggregateByDateRange(
string $filterName,
string $field,
array $options,
int $applicationType,
array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
int $limit = Aggregation::NO_LIMIT
): self {
if (empty($options)) {
return $thi... | [
"public",
"function",
"aggregateByDateRange",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
",",
"int",
"$",
"applicationType",
",",
"array",
"$",
"aggregationSort",
"=",
"Aggregation",
"::",
"SORT_BY_COUNT_DESC",
"... | Add tags aggregation.
@param string $filterName
@param string $field
@param array $options
@param int $applicationType
@param array $aggregationSort
@param int $limit
@return Query | [
"Add",
"tags",
"aggregation",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L848-L871 |
apisearch-io/php-client | Query/Query.php | Query.getQueryText | public function getQueryText(): string
{
return (
isset($this->filters['_query']) &&
$this->filters['_query'] instanceof Filter
)
? $this->filters['_query']->getValues()[0]
: '';
} | php | public function getQueryText(): string
{
return (
isset($this->filters['_query']) &&
$this->filters['_query'] instanceof Filter
)
? $this->filters['_query']->getValues()[0]
: '';
} | [
"public",
"function",
"getQueryText",
"(",
")",
":",
"string",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"'_query'",
"]",
")",
"&&",
"$",
"this",
"->",
"filters",
"[",
"'_query'",
"]",
"instanceof",
"Filter",
")",
"?",
"$",
... | Return Querytext.
@return string | [
"Return",
"Querytext",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L900-L908 |
apisearch-io/php-client | Query/Query.php | Query.getFilterByField | public function getFilterByField(string $fieldName): ? Filter
{
$fieldPath = Item::getPathByField($fieldName);
foreach ($this->getFilters() as $filter) {
if ($fieldPath === $filter->getField()) {
return $filter;
}
}
return null;
} | php | public function getFilterByField(string $fieldName): ? Filter
{
$fieldPath = Item::getPathByField($fieldName);
foreach ($this->getFilters() as $filter) {
if ($fieldPath === $filter->getField()) {
return $filter;
}
}
return null;
} | [
"public",
"function",
"getFilterByField",
"(",
"string",
"$",
"fieldName",
")",
":",
"?",
"Filter",
"{",
"$",
"fieldPath",
"=",
"Item",
"::",
"getPathByField",
"(",
"$",
"fieldName",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFilters",
"(",
")",
"a... | Get filter.
@param string $fieldName
@return Filter|null | [
"Get",
"filter",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L961-L971 |
apisearch-io/php-client | Query/Query.php | Query.excludeUUIDs | public function excludeUUIDs(array $uuids): self
{
$this->filters['excluded_ids'] = Filter::create(
'_id',
array_map(function (ItemUUID $uuid) {
return $uuid->composeUUID();
}, $uuids),
Filter::EXCLUDE,
Filter::TYPE_FIELD
);... | php | public function excludeUUIDs(array $uuids): self
{
$this->filters['excluded_ids'] = Filter::create(
'_id',
array_map(function (ItemUUID $uuid) {
return $uuid->composeUUID();
}, $uuids),
Filter::EXCLUDE,
Filter::TYPE_FIELD
);... | [
"public",
"function",
"excludeUUIDs",
"(",
"array",
"$",
"uuids",
")",
":",
"self",
"{",
"$",
"this",
"->",
"filters",
"[",
"'excluded_ids'",
"]",
"=",
"Filter",
"::",
"create",
"(",
"'_id'",
",",
"array_map",
"(",
"function",
"(",
"ItemUUID",
"$",
"uuid... | Exclude reference.
@param ItemUUID[] $uuids
@return Query | [
"Exclude",
"reference",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L1194-L1206 |
apisearch-io/php-client | Query/Query.php | Query.setMetadataValue | public function setMetadataValue(
string $name,
$value
): self {
$this->metadata[$name] = $value;
return $this;
} | php | public function setMetadataValue(
string $name,
$value
): self {
$this->metadata[$name] = $value;
return $this;
} | [
"public",
"function",
"setMetadataValue",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set metadata.
@param string $name
@param mixed $value
@return Query | [
"Set",
"metadata",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L1350-L1357 |
apisearch-io/php-client | Query/Query.php | Query.addSubQuery | public function addSubQuery(
string $name,
Query $query
): self {
$this->subqueries[$name] = $query;
return $this;
} | php | public function addSubQuery(
string $name,
Query $query
): self {
$this->subqueries[$name] = $query;
return $this;
} | [
"public",
"function",
"addSubQuery",
"(",
"string",
"$",
"name",
",",
"Query",
"$",
"query",
")",
":",
"self",
"{",
"$",
"this",
"->",
"subqueries",
"[",
"$",
"name",
"]",
"=",
"$",
"query",
";",
"return",
"$",
"this",
";",
"}"
] | Add subquery.
@param string $name
@param Query $query
@return Query | [
"Add",
"subquery",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L1377-L1384 |
apisearch-io/php-client | Query/Query.php | Query.toArray | public function toArray(): array
{
return array_filter([
'uuid' => $this->UUID,
'q' => '' !== $this->getQueryText()
? $this->getQueryText()
: null,
'fields' => $this->getFields(),
'coordinate' => $this->coordinate instanceof Htt... | php | public function toArray(): array
{
return array_filter([
'uuid' => $this->UUID,
'q' => '' !== $this->getQueryText()
? $this->getQueryText()
: null,
'fields' => $this->getFields(),
'coordinate' => $this->coordinate instanceof Htt... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'uuid'",
"=>",
"$",
"this",
"->",
"UUID",
",",
"'q'",
"=>",
"''",
"!==",
"$",
"this",
"->",
"getQueryText",
"(",
")",
"?",
"$",
"this",
"->",
"getQuery... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L1449-L1522 |
apisearch-io/php-client | Query/Query.php | Query.createFromArray | public static function createFromArray(array $array): self
{
$query = isset($array['coordinate'])
? self::createLocated(
Coordinate::createFromArray($array['coordinate']),
$array['q'] ?? '',
(int) ($array['page'] ?? self::DEFAULT_PAGE),
... | php | public static function createFromArray(array $array): self
{
$query = isset($array['coordinate'])
? self::createLocated(
Coordinate::createFromArray($array['coordinate']),
$array['q'] ?? '',
(int) ($array['page'] ?? self::DEFAULT_PAGE),
... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"$",
"query",
"=",
"isset",
"(",
"$",
"array",
"[",
"'coordinate'",
"]",
")",
"?",
"self",
"::",
"createLocated",
"(",
"Coordinate",
"::",
"createFromArra... | Create from array.
@param array $array
@return Query | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Query.php#L1531-L1594 |
apisearch-io/php-client | Http/HttpResponsesToException.php | HttpResponsesToException.throwTransportableExceptionIfNeeded | protected static function throwTransportableExceptionIfNeeded(
array $response,
string $url = ''
) {
if (
!isset($response['code']) ||
0 === $response['code']
) {
throw ConnectionException::buildConnectExceptionByUrl($url);
}
switc... | php | protected static function throwTransportableExceptionIfNeeded(
array $response,
string $url = ''
) {
if (
!isset($response['code']) ||
0 === $response['code']
) {
throw ConnectionException::buildConnectExceptionByUrl($url);
}
switc... | [
"protected",
"static",
"function",
"throwTransportableExceptionIfNeeded",
"(",
"array",
"$",
"response",
",",
"string",
"$",
"url",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"[",
"'code'",
"]",
")",
"||",
"0",
"===",
"$",
"respo... | Transform transportable http errors to exceptions.
@param array $response
@param string $url
@throw TransportableException | [
"Transform",
"transportable",
"http",
"errors",
"to",
"exceptions",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/HttpResponsesToException.php#L38-L63 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.fromItems | public function fromItems(array $items): array
{
$objects = [];
foreach ($items as $item) {
$objects[] = $this->fromItem($item);
}
return $objects;
} | php | public function fromItems(array $items): array
{
$objects = [];
foreach ($items as $item) {
$objects[] = $this->fromItem($item);
}
return $objects;
} | [
"public",
"function",
"fromItems",
"(",
"array",
"$",
"items",
")",
":",
"array",
"{",
"$",
"objects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"this",
"->",
"fromItem",
"(... | Transform a set of items into a set of objects.
@param Item[] $items
@return array | [
"Transform",
"a",
"set",
"of",
"items",
"into",
"a",
"set",
"of",
"objects",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L85-L93 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.fromItem | public function fromItem(Item $item)
{
foreach ($this->readTransformers as $readTransformer) {
if ($readTransformer->isValidItem($item)) {
return $readTransformer->fromItem($item);
}
}
return $item;
} | php | public function fromItem(Item $item)
{
foreach ($this->readTransformers as $readTransformer) {
if ($readTransformer->isValidItem($item)) {
return $readTransformer->fromItem($item);
}
}
return $item;
} | [
"public",
"function",
"fromItem",
"(",
"Item",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"readTransformers",
"as",
"$",
"readTransformer",
")",
"{",
"if",
"(",
"$",
"readTransformer",
"->",
"isValidItem",
"(",
"$",
"item",
")",
")",
"{",
... | Transform an item into an object.
@param Item $item
@return mixed | [
"Transform",
"an",
"item",
"into",
"an",
"object",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L102-L111 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.toItems | public function toItems(array $objects): array
{
$items = [];
foreach ($objects as $object) {
$item = $this->toItem($object);
if ($item instanceof Item) {
$items[] = $item;
}
}
return $items;
} | php | public function toItems(array $objects): array
{
$items = [];
foreach ($objects as $object) {
$item = $this->toItem($object);
if ($item instanceof Item) {
$items[] = $item;
}
}
return $items;
} | [
"public",
"function",
"toItems",
"(",
"array",
"$",
"objects",
")",
":",
"array",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"toItem",
"(",
"$",
"obje... | Transform a set of objects into a set of items.
@param array $objects
@return Item[] | [
"Transform",
"a",
"set",
"of",
"objects",
"into",
"a",
"set",
"of",
"items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L120-L131 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.toItem | public function toItem($object): ? Item
{
foreach ($this->writeTransformers as $writeTransformer) {
if ($writeTransformer->isValidObject($object)) {
$item = $writeTransformer->toItem($object);
$this
->eventDispatcher
->dispa... | php | public function toItem($object): ? Item
{
foreach ($this->writeTransformers as $writeTransformer) {
if ($writeTransformer->isValidObject($object)) {
$item = $writeTransformer->toItem($object);
$this
->eventDispatcher
->dispa... | [
"public",
"function",
"toItem",
"(",
"$",
"object",
")",
":",
"?",
"Item",
"{",
"foreach",
"(",
"$",
"this",
"->",
"writeTransformers",
"as",
"$",
"writeTransformer",
")",
"{",
"if",
"(",
"$",
"writeTransformer",
"->",
"isValidObject",
"(",
"$",
"object",
... | Transform an object into an item.
@param mixed $object
@return Item|null | [
"Transform",
"an",
"object",
"into",
"an",
"item",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L140-L160 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.toItemUUIDs | public function toItemUUIDs(array $objects): array
{
$itemUUIDs = [];
foreach ($objects as $object) {
$itemUUID = $this->toItemUUID($object);
if ($itemUUID instanceof ItemUUID) {
$itemUUIDs[] = $itemUUID;
}
}
return $itemUUIDs;
... | php | public function toItemUUIDs(array $objects): array
{
$itemUUIDs = [];
foreach ($objects as $object) {
$itemUUID = $this->toItemUUID($object);
if ($itemUUID instanceof ItemUUID) {
$itemUUIDs[] = $itemUUID;
}
}
return $itemUUIDs;
... | [
"public",
"function",
"toItemUUIDs",
"(",
"array",
"$",
"objects",
")",
":",
"array",
"{",
"$",
"itemUUIDs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"itemUUID",
"=",
"$",
"this",
"->",
"toItemUUID",
"("... | Transform a set of objects into a set of itemUUIDs.
@param array $objects
@return ItemUUID[] | [
"Transform",
"a",
"set",
"of",
"objects",
"into",
"a",
"set",
"of",
"itemUUIDs",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L169-L180 |
apisearch-io/php-client | Transformer/Transformer.php | Transformer.toItemUUID | public function toItemUUID($object): ? ItemUUID
{
foreach ($this->writeTransformers as $writeTransformer) {
if ($writeTransformer->isValidObject($object)) {
return $writeTransformer->toItemUUID($object);
}
}
return null;
} | php | public function toItemUUID($object): ? ItemUUID
{
foreach ($this->writeTransformers as $writeTransformer) {
if ($writeTransformer->isValidObject($object)) {
return $writeTransformer->toItemUUID($object);
}
}
return null;
} | [
"public",
"function",
"toItemUUID",
"(",
"$",
"object",
")",
":",
"?",
"ItemUUID",
"{",
"foreach",
"(",
"$",
"this",
"->",
"writeTransformers",
"as",
"$",
"writeTransformer",
")",
"{",
"if",
"(",
"$",
"writeTransformer",
"->",
"isValidObject",
"(",
"$",
"o... | Transform an object into an itemUUID or return NULL if the object is not
transformable.
@param mixed $object
@return ItemUUID|null | [
"Transform",
"an",
"object",
"into",
"an",
"itemUUID",
"or",
"return",
"NULL",
"if",
"the",
"object",
"is",
"not",
"transformable",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Transformer/Transformer.php#L190-L199 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byFieldsValues | public static function byFieldsValues(array $shortSortByElements): SortBy
{
$sortBy = self::create();
foreach ($shortSortByElements as $field => $order) {
$sortBy->byFieldValue($field, $order);
}
return $sortBy;
} | php | public static function byFieldsValues(array $shortSortByElements): SortBy
{
$sortBy = self::create();
foreach ($shortSortByElements as $field => $order) {
$sortBy->byFieldValue($field, $order);
}
return $sortBy;
} | [
"public",
"static",
"function",
"byFieldsValues",
"(",
"array",
"$",
"shortSortByElements",
")",
":",
"SortBy",
"{",
"$",
"sortBy",
"=",
"self",
"::",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"shortSortByElements",
"as",
"$",
"field",
"=>",
"$",
"orde... | Create sort by with passed simple fields and values.
SortBy::byFieldsValues([
['brand' => 'asc'],
['category' => 'desc'],
]);
@param array $shortSortByElements
@return SortBy | [
"Create",
"sort",
"by",
"with",
"passed",
"simple",
"fields",
"and",
"values",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L233-L241 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byValue | public function byValue(array $value): SortBy
{
if (
self::SCORE !== $value &&
self::RANDOM !== $value
) {
$value['type'] = $value['type'] ?? self::TYPE_FIELD;
}
$this->sortsBy[] = $value;
return $this;
} | php | public function byValue(array $value): SortBy
{
if (
self::SCORE !== $value &&
self::RANDOM !== $value
) {
$value['type'] = $value['type'] ?? self::TYPE_FIELD;
}
$this->sortsBy[] = $value;
return $this;
} | [
"public",
"function",
"byValue",
"(",
"array",
"$",
"value",
")",
":",
"SortBy",
"{",
"if",
"(",
"self",
"::",
"SCORE",
"!==",
"$",
"value",
"&&",
"self",
"::",
"RANDOM",
"!==",
"$",
"value",
")",
"{",
"$",
"value",
"[",
"'type'",
"]",
"=",
"$",
... | Sort by value.
@param array $value
@return SortBy | [
"Sort",
"by",
"value",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L262-L274 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byFieldValue | public function byFieldValue(
string $field,
string $order
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_FIELD,
'field' => Item::getPathByField($field),
'order' => $order,
];
return $this;
} | php | public function byFieldValue(
string $field,
string $order
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_FIELD,
'field' => Item::getPathByField($field),
'order' => $order,
];
return $this;
} | [
"public",
"function",
"byFieldValue",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"order",
")",
":",
"SortBy",
"{",
"$",
"this",
"->",
"sortsBy",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"TYPE_FIELD",
",",
"'field'",
"=>",
"Item",
"::",
... | Sort by field.
@param string $field
@param string $order
@return SortBy | [
"Sort",
"by",
"field",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L284-L295 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byNestedField | public function byNestedField(
string $field,
string $order,
string $mode = self::MODE_AVG
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_NESTED,
'mode' => $mode,
'field' => "indexed_metadata.$field",
'order' => $order,
]... | php | public function byNestedField(
string $field,
string $order,
string $mode = self::MODE_AVG
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_NESTED,
'mode' => $mode,
'field' => "indexed_metadata.$field",
'order' => $order,
]... | [
"public",
"function",
"byNestedField",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"order",
",",
"string",
"$",
"mode",
"=",
"self",
"::",
"MODE_AVG",
")",
":",
"SortBy",
"{",
"$",
"this",
"->",
"sortsBy",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"se... | Sort by nested field and filter.
@param string $field
@param string $order
@param string $mode
@return SortBy | [
"Sort",
"by",
"nested",
"field",
"and",
"filter",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L306-L319 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byNestedFieldAndFilter | public function byNestedFieldAndFilter(
string $field,
string $order,
Filter $filter,
string $mode = self::MODE_AVG
): SortBy {
$fieldPath = Item::getPathByField($filter->getField());
$filterAsArray = $filter->toArray();
$filterAsArray['field'] = $fieldPath;
... | php | public function byNestedFieldAndFilter(
string $field,
string $order,
Filter $filter,
string $mode = self::MODE_AVG
): SortBy {
$fieldPath = Item::getPathByField($filter->getField());
$filterAsArray = $filter->toArray();
$filterAsArray['field'] = $fieldPath;
... | [
"public",
"function",
"byNestedFieldAndFilter",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"order",
",",
"Filter",
"$",
"filter",
",",
"string",
"$",
"mode",
"=",
"self",
"::",
"MODE_AVG",
")",
":",
"SortBy",
"{",
"$",
"fieldPath",
"=",
"Item",
"::... | Sort by nested field and filter.
@param string $field
@param string $order
@param Filter $filter
@param string $mode
@return SortBy | [
"Sort",
"by",
"nested",
"field",
"and",
"filter",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L331-L350 |
apisearch-io/php-client | Query/SortBy.php | SortBy.byFunction | public function byFunction(
string $function,
string $order
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_FUNCTION,
'function' => $function,
'order' => $order,
];
return $this;
} | php | public function byFunction(
string $function,
string $order
): SortBy {
$this->sortsBy[] = [
'type' => self::TYPE_FUNCTION,
'function' => $function,
'order' => $order,
];
return $this;
} | [
"public",
"function",
"byFunction",
"(",
"string",
"$",
"function",
",",
"string",
"$",
"order",
")",
":",
"SortBy",
"{",
"$",
"this",
"->",
"sortsBy",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"TYPE_FUNCTION",
",",
"'function'",
"=>",
"$",
"fu... | Sort by function.
@param string $function
@param string $order
@return SortBy | [
"Sort",
"by",
"function",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L360-L371 |
apisearch-io/php-client | Query/SortBy.php | SortBy.isSortedByGeoDistance | public function isSortedByGeoDistance(): bool
{
foreach ($this->sortsBy as $sortBy) {
if (self::TYPE_DISTANCE === $sortBy['type']) {
return true;
}
}
return false;
} | php | public function isSortedByGeoDistance(): bool
{
foreach ($this->sortsBy as $sortBy) {
if (self::TYPE_DISTANCE === $sortBy['type']) {
return true;
}
}
return false;
} | [
"public",
"function",
"isSortedByGeoDistance",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sortsBy",
"as",
"$",
"sortBy",
")",
"{",
"if",
"(",
"self",
"::",
"TYPE_DISTANCE",
"===",
"$",
"sortBy",
"[",
"'type'",
"]",
")",
"{",
"retur... | Is sorted by geo distance.
@return bool | [
"Is",
"sorted",
"by",
"geo",
"distance",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L378-L387 |
apisearch-io/php-client | Query/SortBy.php | SortBy.setCoordinate | public function setCoordinate(Coordinate $coordinate)
{
$this->sortsBy = array_map(function (array $sortBy) use ($coordinate) {
if (self::TYPE_DISTANCE === $sortBy['type']) {
$sortBy['coordinate'] = $coordinate;
}
return $sortBy;
}, $this->sortsBy... | php | public function setCoordinate(Coordinate $coordinate)
{
$this->sortsBy = array_map(function (array $sortBy) use ($coordinate) {
if (self::TYPE_DISTANCE === $sortBy['type']) {
$sortBy['coordinate'] = $coordinate;
}
return $sortBy;
}, $this->sortsBy... | [
"public",
"function",
"setCoordinate",
"(",
"Coordinate",
"$",
"coordinate",
")",
"{",
"$",
"this",
"->",
"sortsBy",
"=",
"array_map",
"(",
"function",
"(",
"array",
"$",
"sortBy",
")",
"use",
"(",
"$",
"coordinate",
")",
"{",
"if",
"(",
"self",
"::",
... | Set coordinate.
@param Coordinate $coordinate
@return SortBy | [
"Set",
"coordinate",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L396-L407 |
apisearch-io/php-client | Query/SortBy.php | SortBy.toArray | public function toArray(): array
{
return array_map(function (array $sortBy) {
if (
isset($sortBy['filter']) &&
($sortBy['filter'] instanceof Filter)
) {
$sortBy['filter'] = $sortBy['filter']->toArray();
}
if (
... | php | public function toArray(): array
{
return array_map(function (array $sortBy) {
if (
isset($sortBy['filter']) &&
($sortBy['filter'] instanceof Filter)
) {
$sortBy['filter'] = $sortBy['filter']->toArray();
}
if (
... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"array",
"$",
"sortBy",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"sortBy",
"[",
"'filter'",
"]",
")",
"&&",
"(",
"$",
"sortBy",
"[",
"'filter'",... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L414-L433 |
apisearch-io/php-client | Query/SortBy.php | SortBy.createFromArray | public static function createFromArray(array $array)
{
$sortBy = self::create();
$sortBy->sortsBy = array_map(function (array $element) {
if (
self::RANDOM !== $element &&
self::SCORE !== $element
) {
$element['type'] = $element... | php | public static function createFromArray(array $array)
{
$sortBy = self::create();
$sortBy->sortsBy = array_map(function (array $element) {
if (
self::RANDOM !== $element &&
self::SCORE !== $element
) {
$element['type'] = $element... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"sortBy",
"=",
"self",
"::",
"create",
"(",
")",
";",
"$",
"sortBy",
"->",
"sortsBy",
"=",
"array_map",
"(",
"function",
"(",
"array",
"$",
"element",
")",
"{... | Create from array.
@param array $array
@return self
@throws InvalidFormatException | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L444-L470 |
apisearch-io/php-client | Query/SortBy.php | SortBy.hasRandomSort | public function hasRandomSort()
{
foreach ($this->sortsBy as $sortBy) {
if (self::TYPE_RANDOM === $sortBy['type']) {
return true;
}
}
return false;
} | php | public function hasRandomSort()
{
foreach ($this->sortsBy as $sortBy) {
if (self::TYPE_RANDOM === $sortBy['type']) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasRandomSort",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sortsBy",
"as",
"$",
"sortBy",
")",
"{",
"if",
"(",
"self",
"::",
"TYPE_RANDOM",
"===",
"$",
"sortBy",
"[",
"'type'",
"]",
")",
"{",
"return",
"true",
";",
"}",... | Has random sort.
@return bool | [
"Has",
"random",
"sort",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/SortBy.php#L477-L486 |
apisearch-io/php-client | Query/Filter.php | Filter.create | public static function create(
string $field,
array $values,
int $applicationType,
string $filterType,
array $filterTerms = []
): self {
return new self(
$field,
$values,
$applicationType,
$filterType,
$filte... | php | public static function create(
string $field,
array $values,
int $applicationType,
string $filterType,
array $filterTerms = []
): self {
return new self(
$field,
$values,
$applicationType,
$filterType,
$filte... | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"int",
"$",
"applicationType",
",",
"string",
"$",
"filterType",
",",
"array",
"$",
"filterTerms",
"=",
"[",
"]",
")",
":",
"self",
"{",
"return",
... | Create filter.
@param string $field
@param array $values
@param int $applicationType
@param string $filterType
@param array $filterTerms
@return Filter | [
"Create",
"filter",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Filter.php#L229-L243 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.