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 | Query/Filter.php | Filter.toArray | public function toArray(): array
{
return array_filter([
'field' => 'uuid.type' === $this->field
? null
: $this->field,
'values' => $this->values,
'application_type' => self::AT_LEAST_ONE === $this->applicationType
? null
... | php | public function toArray(): array
{
return array_filter([
'field' => 'uuid.type' === $this->field
? null
: $this->field,
'values' => $this->values,
'application_type' => self::AT_LEAST_ONE === $this->applicationType
? null
... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'field'",
"=>",
"'uuid.type'",
"===",
"$",
"this",
"->",
"field",
"?",
"null",
":",
"$",
"this",
"->",
"field",
",",
"'values'",
"=>",
"$",
"this",
"->",... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Filter.php#L250-L271 |
apisearch-io/php-client | Query/Filter.php | Filter.createFromArray | public static function createFromArray(array $array): self
{
if (
isset($array['values']) &&
!is_array($array['values'])
) {
throw InvalidFormatException::queryFormatNotValid($array);
}
return self::create(
$array['field'] ?? 'uuid.typ... | php | public static function createFromArray(array $array): self
{
if (
isset($array['values']) &&
!is_array($array['values'])
) {
throw InvalidFormatException::queryFormatNotValid($array);
}
return self::create(
$array['field'] ?? 'uuid.typ... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"'values'",
"]",
")",
"&&",
"!",
"is_array",
"(",
"$",
"array",
"[",
"'values'",
"]",
")",
")",
"{",
"... | Create from array.
@param array $array
@return Filter | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Filter.php#L280-L296 |
apisearch-io/php-client | Http/Retry.php | Retry.createFromArray | public static function createFromArray(array $data): Retry
{
return new Retry(
(string) (trim(trim(strtolower($data['url'] ?? '*')), '/')),
(string) (trim(strtolower($data['method'] ?? '*'))),
(int) ($data['retries'] ?? 0),
(int) ($data['microseconds_between_r... | php | public static function createFromArray(array $data): Retry
{
return new Retry(
(string) (trim(trim(strtolower($data['url'] ?? '*')), '/')),
(string) (trim(strtolower($data['method'] ?? '*'))),
(int) ($data['retries'] ?? 0),
(int) ($data['microseconds_between_r... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"data",
")",
":",
"Retry",
"{",
"return",
"new",
"Retry",
"(",
"(",
"string",
")",
"(",
"trim",
"(",
"trim",
"(",
"strtolower",
"(",
"$",
"data",
"[",
"'url'",
"]",
"??",
"'*'",
")... | Create from array.
@param array $data
@return Retry | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/Retry.php#L85-L93 |
apisearch-io/php-client | Http/CurlAdapter.php | CurlAdapter.getByRequestParts | public function getByRequestParts(
string $host,
string $method,
RequestParts $requestParts
): array {
$json = json_encode($requestParts->getParameters()['json']);
$formattedUrl = rtrim($host, '/').'/'.ltrim($requestParts->getUrl(), '/');
$method = strtoupper($method)... | php | public function getByRequestParts(
string $host,
string $method,
RequestParts $requestParts
): array {
$json = json_encode($requestParts->getParameters()['json']);
$formattedUrl = rtrim($host, '/').'/'.ltrim($requestParts->getUrl(), '/');
$method = strtoupper($method)... | [
"public",
"function",
"getByRequestParts",
"(",
"string",
"$",
"host",
",",
"string",
"$",
"method",
",",
"RequestParts",
"$",
"requestParts",
")",
":",
"array",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"requestParts",
"->",
"getParameters",
"(",
")",... | Get.
@param string $host
@param string $method
@param RequestParts $requestParts
@return array
@throws ConnectionException | [
"Get",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/CurlAdapter.php#L36-L80 |
apisearch-io/php-client | Http/Client.php | Client.buildRequestParts | public function buildRequestParts(
string $url,
array $query = [],
array $body = [],
array $server = []
): RequestParts {
$url = trim($url, '/');
$url = trim("{$this->version}/$url", '/');
$url = $this->buildUrlParams($url, $query);
return new Request... | php | public function buildRequestParts(
string $url,
array $query = [],
array $body = [],
array $server = []
): RequestParts {
$url = trim($url, '/');
$url = trim("{$this->version}/$url", '/');
$url = $this->buildUrlParams($url, $query);
return new Request... | [
"public",
"function",
"buildRequestParts",
"(",
"string",
"$",
"url",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"server",
"=",
"[",
"]",
")",
":",
"RequestParts",
"{",
"$",
"url",
"=",
... | Get some parameters and build a RequestParts instance.
@param string $url
@param array $query
@param array $body
@param array $server
@return RequestParts | [
"Get",
"some",
"parameters",
"and",
"build",
"a",
"RequestParts",
"instance",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/Client.php#L61-L81 |
apisearch-io/php-client | Http/Client.php | Client.buildUrlParams | private function buildUrlParams(
string $url,
array $params
) {
array_walk($params, function (&$value, $key) {
$value = "$key=$value";
});
return $url.'?'.implode('&', $params);
} | php | private function buildUrlParams(
string $url,
array $params
) {
array_walk($params, function (&$value, $key) {
$value = "$key=$value";
});
return $url.'?'.implode('&', $params);
} | [
"private",
"function",
"buildUrlParams",
"(",
"string",
"$",
"url",
",",
"array",
"$",
"params",
")",
"{",
"array_walk",
"(",
"$",
"params",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"\"$key=$value\"",
";",
... | Build url params.
@param string $url
@param string[] $params
@return string | [
"Build",
"url",
"params",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/Client.php#L91-L100 |
apisearch-io/php-client | Exporter/JSONExporter.php | JSONExporter.formatToItems | public function formatToItems(string $data): array
{
return array_map(function (array $item) {
$itemAsArray = [
'uuid' => [
'id' => $item[0],
'type' => $item[1],
],
'metadata' => $item[2],
'in... | php | public function formatToItems(string $data): array
{
return array_map(function (array $item) {
$itemAsArray = [
'uuid' => [
'id' => $item[0],
'type' => $item[1],
],
'metadata' => $item[2],
'in... | [
"public",
"function",
"formatToItems",
"(",
"string",
"$",
"data",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"array",
"$",
"item",
")",
"{",
"$",
"itemAsArray",
"=",
"[",
"'uuid'",
"=>",
"[",
"'id'",
"=>",
"$",
"item",
"[",
... | 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/JSONExporter.php#L78-L99 |
apisearch-io/php-client | Exception/ExporterNotAvailableException.php | ExporterNotAvailableException.createForMissingDependency | public static function createForMissingDependency(
string $format,
string $missingClass,
string $package
): self {
return new self(sprintf('Exporter %s not available. Missing class %s. To resolve it, add %d in your composer',
$format,
$missingClass,
... | php | public static function createForMissingDependency(
string $format,
string $missingClass,
string $package
): self {
return new self(sprintf('Exporter %s not available. Missing class %s. To resolve it, add %d in your composer',
$format,
$missingClass,
... | [
"public",
"static",
"function",
"createForMissingDependency",
"(",
"string",
"$",
"format",
",",
"string",
"$",
"missingClass",
",",
"string",
"$",
"package",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"sprintf",
"(",
"'Exporter %s not available. Missing... | Create exporter not available because of missing dependency.
@param string $format
@param string $missingClass
@param string $package
@return ExporterNotAvailableException | [
"Create",
"exporter",
"not",
"available",
"because",
"of",
"missing",
"dependency",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Exception/ExporterNotAvailableException.php#L34-L44 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.guessFilterValue | public function guessFilterValue(
Result $result,
Aggregation $aggregation,
Counter $counter
): string {
return $counter->isUsed()
? $this->removeFilterValue(
$result,
$aggregation->getName(),
$counter->getId()
)... | php | public function guessFilterValue(
Result $result,
Aggregation $aggregation,
Counter $counter
): string {
return $counter->isUsed()
? $this->removeFilterValue(
$result,
$aggregation->getName(),
$counter->getId()
)... | [
"public",
"function",
"guessFilterValue",
"(",
"Result",
"$",
"result",
",",
"Aggregation",
"$",
"aggregation",
",",
"Counter",
"$",
"counter",
")",
":",
"string",
"{",
"return",
"$",
"counter",
"->",
"isUsed",
"(",
")",
"?",
"$",
"this",
"->",
"removeFilt... | Guess filter value.
@param Result $result
@param Aggregation $aggregation
@param Counter $counter
@return string | [
"Guess",
"filter",
"value",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L79-L95 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.addFilterValue | public function addFilterValue(
Result $result,
string $filterName,
string $value
): string {
if (isset($this->routesCache[spl_object_hash($result)][$filterName])) {
return str_replace(
['{id}', '{slug}'],
$result->getAggregation($filterNam... | php | public function addFilterValue(
Result $result,
string $filterName,
string $value
): string {
if (isset($this->routesCache[spl_object_hash($result)][$filterName])) {
return str_replace(
['{id}', '{slug}'],
$result->getAggregation($filterNam... | [
"public",
"function",
"addFilterValue",
"(",
"Result",
"$",
"result",
",",
"string",
"$",
"filterName",
",",
"string",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routesCache",
"[",
"spl_object_hash",
"(",
"$",
"re... | Add filter into query.
@param Result $result
@param string $filterName
@param string $value
@return string | [
"Add",
"filter",
"into",
"query",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L106-L151 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.removeFilterValue | public function removeFilterValue(
Result $result,
string $filterName,
string $value = null
): string {
$urlParameters = $this->generateQueryUrlParameters($result);
if (
is_null($value) ||
!isset($urlParameters[$filterName])
) {
un... | php | public function removeFilterValue(
Result $result,
string $filterName,
string $value = null
): string {
$urlParameters = $this->generateQueryUrlParameters($result);
if (
is_null($value) ||
!isset($urlParameters[$filterName])
) {
un... | [
"public",
"function",
"removeFilterValue",
"(",
"Result",
"$",
"result",
",",
"string",
"$",
"filterName",
",",
"string",
"$",
"value",
"=",
"null",
")",
":",
"string",
"{",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$"... | Remove filter from query.
@param Result $result
@param string $filterName
@param string $value
@return string | [
"Remove",
"filter",
"from",
"query",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L162-L182 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.removePriceRangeFilter | public function removePriceRangeFilter(Result $result): string
{
$urlParameters = $this->generateQueryUrlParameters($result);
unset($urlParameters['price']);
return $this->createUrlByUrlParameters(
$result,
$urlParameters
)['route'];
} | php | public function removePriceRangeFilter(Result $result): string
{
$urlParameters = $this->generateQueryUrlParameters($result);
unset($urlParameters['price']);
return $this->createUrlByUrlParameters(
$result,
$urlParameters
)['route'];
} | [
"public",
"function",
"removePriceRangeFilter",
"(",
"Result",
"$",
"result",
")",
":",
"string",
"{",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"result",
")",
";",
"unset",
"(",
"$",
"urlParameters",
"[",
"'price'",... | Change price range.
@param Result $result
@return string | [
"Change",
"price",
"range",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L191-L200 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.getCurrent | public function getCurrent(
Result $result,
bool $addQuersyStringPlaceholder = false
): ? string {
$urlParameters = $this->generateQueryUrlParameters($result);
if ($addQuersyStringPlaceholder) {
$urlParameters['q'] = '{{q}}';
}
return $this->createUrlByUr... | php | public function getCurrent(
Result $result,
bool $addQuersyStringPlaceholder = false
): ? string {
$urlParameters = $this->generateQueryUrlParameters($result);
if ($addQuersyStringPlaceholder) {
$urlParameters['q'] = '{{q}}';
}
return $this->createUrlByUr... | [
"public",
"function",
"getCurrent",
"(",
"Result",
"$",
"result",
",",
"bool",
"$",
"addQuersyStringPlaceholder",
"=",
"false",
")",
":",
"?",
"string",
"{",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"result",
")",
... | Get current.
@param Result $result
@param bool $addQuersyStringPlaceholder
@return string | [
"Get",
"current",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L210-L223 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.addPage | public function addPage(
Result $result,
int $page
): string {
$urlParameters = $this->generateQueryUrlParameters($result);
$urlParameters['page'] = $page;
return $this->createUrlByUrlParameters(
$result,
$urlParameters
)['route'];
} | php | public function addPage(
Result $result,
int $page
): string {
$urlParameters = $this->generateQueryUrlParameters($result);
$urlParameters['page'] = $page;
return $this->createUrlByUrlParameters(
$result,
$urlParameters
)['route'];
} | [
"public",
"function",
"addPage",
"(",
"Result",
"$",
"result",
",",
"int",
"$",
"page",
")",
":",
"string",
"{",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"result",
")",
";",
"$",
"urlParameters",
"[",
"'page'",
... | Set pagination.
@param Result $result
@param int $page
@return string | [
"Set",
"pagination",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L233-L244 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.addPrevPage | public function addPrevPage(Result $result): ? string
{
$query = $result->getQuery();
$urlParameters = $this->generateQueryUrlParameters($result);
$page = $query->getPage();
$prevPage = $page - 1;
if ($prevPage < 1) {
return null;
}
$urlParameter... | php | public function addPrevPage(Result $result): ? string
{
$query = $result->getQuery();
$urlParameters = $this->generateQueryUrlParameters($result);
$page = $query->getPage();
$prevPage = $page - 1;
if ($prevPage < 1) {
return null;
}
$urlParameter... | [
"public",
"function",
"addPrevPage",
"(",
"Result",
"$",
"result",
")",
":",
"?",
"string",
"{",
"$",
"query",
"=",
"$",
"result",
"->",
"getQuery",
"(",
")",
";",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"res... | Add previous page.
@param Result $result
@return string|null | [
"Add",
"previous",
"page",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L253-L270 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.addNextPage | public function addNextPage(Result $result): ? string
{
$query = $result->getQuery();
$urlParameters = $this->generateQueryUrlParameters($result);
$page = $query->getPage();
$nextPage = $page + 1;
if ((($nextPage - 1) * $query->getSize()) > $result->getTotalHits()) {
... | php | public function addNextPage(Result $result): ? string
{
$query = $result->getQuery();
$urlParameters = $this->generateQueryUrlParameters($result);
$page = $query->getPage();
$nextPage = $page + 1;
if ((($nextPage - 1) * $query->getSize()) > $result->getTotalHits()) {
... | [
"public",
"function",
"addNextPage",
"(",
"Result",
"$",
"result",
")",
":",
"?",
"string",
"{",
"$",
"query",
"=",
"$",
"result",
"->",
"getQuery",
"(",
")",
";",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"res... | Add next page.
@param Result $result
@return string|null | [
"Add",
"next",
"page",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L279-L296 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.addSortBy | public function addSortBy(
Result $result,
string $field,
string $mode
): ? string {
$urlParameters = $this->generateQueryUrlParameters($result);
if (
isset($urlParameters['sort_by'][$field]) &&
$urlParameters['sort_by'][$field] == $mode
) {
... | php | public function addSortBy(
Result $result,
string $field,
string $mode
): ? string {
$urlParameters = $this->generateQueryUrlParameters($result);
if (
isset($urlParameters['sort_by'][$field]) &&
$urlParameters['sort_by'][$field] == $mode
) {
... | [
"public",
"function",
"addSortBy",
"(",
"Result",
"$",
"result",
",",
"string",
"$",
"field",
",",
"string",
"$",
"mode",
")",
":",
"?",
"string",
"{",
"$",
"urlParameters",
"=",
"$",
"this",
"->",
"generateQueryUrlParameters",
"(",
"$",
"result",
")",
"... | Add sort by. Return null if doesn't change.
@param Result $result
@param string $field
@param string $mode
@return string | [
"Add",
"sort",
"by",
".",
"Return",
"null",
"if",
"doesn",
"t",
"change",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L307-L338 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.generateQueryUrlParameters | private function generateQueryUrlParameters(
Result $result,
string $filterName = null
): array {
$query = $result->getQuery();
$queryFilters = $query->getFilters();
$urlParameters = [];
foreach ($queryFilters as $currentFilterName => $filter) {
/*
... | php | private function generateQueryUrlParameters(
Result $result,
string $filterName = null
): array {
$query = $result->getQuery();
$queryFilters = $query->getFilters();
$urlParameters = [];
foreach ($queryFilters as $currentFilterName => $filter) {
/*
... | [
"private",
"function",
"generateQueryUrlParameters",
"(",
"Result",
"$",
"result",
",",
"string",
"$",
"filterName",
"=",
"null",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"result",
"->",
"getQuery",
"(",
")",
";",
"$",
"queryFilters",
"=",
"$",
"q... | Query to url parameters.
@param Result $result
@param string $filterName
@return array | [
"Query",
"to",
"url",
"parameters",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L348-L385 |
apisearch-io/php-client | Url/UrlBuilder.php | UrlBuilder.createUrlByUrlParameters | private function createUrlByUrlParameters(
Result $result,
array $urlParameters
): array {
foreach ($this->routesDictionary as $field => $route) {
if (
!isset($urlParameters[$field]) ||
(
is_array($urlParameters[$field]) &&
... | php | private function createUrlByUrlParameters(
Result $result,
array $urlParameters
): array {
foreach ($this->routesDictionary as $field => $route) {
if (
!isset($urlParameters[$field]) ||
(
is_array($urlParameters[$field]) &&
... | [
"private",
"function",
"createUrlByUrlParameters",
"(",
"Result",
"$",
"result",
",",
"array",
"$",
"urlParameters",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routesDictionary",
"as",
"$",
"field",
"=>",
"$",
"route",
")",
"{",
"if",
"(",... | Generate url by query parameters.
Given a route dictionary, we should apply the first one encontered
@param Result $result
@param array $urlParameters
@return string[] | [
"Generate",
"url",
"by",
"query",
"parameters",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Url/UrlBuilder.php#L397-L476 |
apisearch-io/php-client | Model/Changes.php | Changes.addChange | public function addChange(
string $field,
$value,
int $type = self::TYPE_VALUE
): self {
$this->changes[] = [
'field' => $field,
'type' => $type,
'value' => $value,
];
return $this;
} | php | public function addChange(
string $field,
$value,
int $type = self::TYPE_VALUE
): self {
$this->changes[] = [
'field' => $field,
'type' => $type,
'value' => $value,
];
return $this;
} | [
"public",
"function",
"addChange",
"(",
"string",
"$",
"field",
",",
"$",
"value",
",",
"int",
"$",
"type",
"=",
"self",
"::",
"TYPE_VALUE",
")",
":",
"self",
"{",
"$",
"this",
"->",
"changes",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
","... | Add change.
@param string $field
@param mixed $value
@param int $type
@return Changes | [
"Add",
"change",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Changes.php#L90-L102 |
apisearch-io/php-client | Model/Changes.php | Changes.updateElementFromList | public function updateElementFromList(
string $field,
string $condition,
$value,
int $type
): self {
$this->changes[] = [
'field' => $field,
'type' => $type | self::TYPE_ARRAY_ELEMENT_UPDATE,
'condition' => $condition,
'value' =... | php | public function updateElementFromList(
string $field,
string $condition,
$value,
int $type
): self {
$this->changes[] = [
'field' => $field,
'type' => $type | self::TYPE_ARRAY_ELEMENT_UPDATE,
'condition' => $condition,
'value' =... | [
"public",
"function",
"updateElementFromList",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"condition",
",",
"$",
"value",
",",
"int",
"$",
"type",
")",
":",
"self",
"{",
"$",
"this",
"->",
"changes",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"f... | Add change inside a list.
@param string $field
@param string $condition
@param mixed $value
@param int $type
@return Changes | [
"Add",
"change",
"inside",
"a",
"list",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Changes.php#L114-L128 |
apisearch-io/php-client | Model/Changes.php | Changes.addElementInList | public function addElementInList(
string $field,
$value,
int $type
): self {
$this->changes[] = [
'field' => $field,
'type' => $type | self::TYPE_ARRAY_ELEMENT_ADD,
'value' => $value,
];
return $this;
} | php | public function addElementInList(
string $field,
$value,
int $type
): self {
$this->changes[] = [
'field' => $field,
'type' => $type | self::TYPE_ARRAY_ELEMENT_ADD,
'value' => $value,
];
return $this;
} | [
"public",
"function",
"addElementInList",
"(",
"string",
"$",
"field",
",",
"$",
"value",
",",
"int",
"$",
"type",
")",
":",
"self",
"{",
"$",
"this",
"->",
"changes",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'type'",
"=>",
"$",
"ty... | Add change inside a list.
@param string $field
@param mixed $value
@param int $type
@return Changes | [
"Add",
"change",
"inside",
"a",
"list",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Changes.php#L139-L151 |
apisearch-io/php-client | Model/Changes.php | Changes.deleteElementFromList | public function deleteElementFromList(
string $field,
string $condition
): self {
$this->changes[] = [
'field' => $field,
'type' => self::TYPE_ARRAY_ELEMENT_DELETE,
'condition' => $condition,
];
return $this;
} | php | public function deleteElementFromList(
string $field,
string $condition
): self {
$this->changes[] = [
'field' => $field,
'type' => self::TYPE_ARRAY_ELEMENT_DELETE,
'condition' => $condition,
];
return $this;
} | [
"public",
"function",
"deleteElementFromList",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"condition",
")",
":",
"self",
"{",
"$",
"this",
"->",
"changes",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'type'",
"=>",
"self",
"::",
"TYP... | Delete change from a list.
@param string $field
@param string $condition
@return Changes | [
"Delete",
"change",
"from",
"a",
"list",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Changes.php#L161-L172 |
apisearch-io/php-client | Query/ScoreStrategies.php | ScoreStrategies.createEmpty | public static function createEmpty(string $scoreMode = self::SUM): self
{
$scoreStrategies = new self();
$scoreStrategies->scoreMode = $scoreMode;
return $scoreStrategies;
} | php | public static function createEmpty(string $scoreMode = self::SUM): self
{
$scoreStrategies = new self();
$scoreStrategies->scoreMode = $scoreMode;
return $scoreStrategies;
} | [
"public",
"static",
"function",
"createEmpty",
"(",
"string",
"$",
"scoreMode",
"=",
"self",
"::",
"SUM",
")",
":",
"self",
"{",
"$",
"scoreStrategies",
"=",
"new",
"self",
"(",
")",
";",
"$",
"scoreStrategies",
"->",
"scoreMode",
"=",
"$",
"scoreMode",
... | Create empty.
@param string $scoreMode
@return self | [
"Create",
"empty",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategies.php#L81-L87 |
apisearch-io/php-client | Query/ScoreStrategies.php | ScoreStrategies.toArray | public function toArray(): array
{
return [
'score_mode' => $this->scoreMode,
'score_strategies' => array_map(function (ScoreStrategy $scoreStrategy) {
return $scoreStrategy->toArray();
}, $this->scoreStrategies),
];
} | php | public function toArray(): array
{
return [
'score_mode' => $this->scoreMode,
'score_strategies' => array_map(function (ScoreStrategy $scoreStrategy) {
return $scoreStrategy->toArray();
}, $this->scoreStrategies),
];
} | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'score_mode'",
"=>",
"$",
"this",
"->",
"scoreMode",
",",
"'score_strategies'",
"=>",
"array_map",
"(",
"function",
"(",
"ScoreStrategy",
"$",
"scoreStrategy",
")",
"{",
"return",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategies.php#L128-L136 |
apisearch-io/php-client | Query/ScoreStrategies.php | ScoreStrategies.createFromArray | public static function createFromArray(array $array)
{
$scoreStrategies = new self();
$scoreStrategies->scoreMode = $array['score_mode'] ?: self::SUM;
$scoreStrategies->scoreStrategies = array_map(function (array $scoreStrategy) {
return ScoreStrategy::createFromArray($scoreStrat... | php | public static function createFromArray(array $array)
{
$scoreStrategies = new self();
$scoreStrategies->scoreMode = $array['score_mode'] ?: self::SUM;
$scoreStrategies->scoreStrategies = array_map(function (array $scoreStrategy) {
return ScoreStrategy::createFromArray($scoreStrat... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"scoreStrategies",
"=",
"new",
"self",
"(",
")",
";",
"$",
"scoreStrategies",
"->",
"scoreMode",
"=",
"$",
"array",
"[",
"'score_mode'",
"]",
"?",
":",
"self",
... | Create from array.
@param array $array
@return self | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/ScoreStrategies.php#L145-L154 |
apisearch-io/php-client | User/Interaction.php | Interaction.toArray | public function toArray(): array
{
return array_filter([
'user' => $this->user->toArray(),
'item_uuid' => $this->itemUUID->toArray(),
'event_name' => $this->eventName,
'metadata' => $this->metadata,
]);
} | php | public function toArray(): array
{
return array_filter([
'user' => $this->user->toArray(),
'item_uuid' => $this->itemUUID->toArray(),
'event_name' => $this->eventName,
'metadata' => $this->metadata,
]);
} | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'user'",
"=>",
"$",
"this",
"->",
"user",
"->",
"toArray",
"(",
")",
",",
"'item_uuid'",
"=>",
"$",
"this",
"->",
"itemUUID",
"->",
"toArray",
"(",
")",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/User/Interaction.php#L121-L129 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.deleteIndex | public function deleteIndex(IndexUUID $indexUUID)
{
$this->load();
parent::deleteIndex($indexUUID);
$this->save();
} | php | public function deleteIndex(IndexUUID $indexUUID)
{
$this->load();
parent::deleteIndex($indexUUID);
$this->save();
} | [
"public",
"function",
"deleteIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"deleteIndex",
"(",
"$",
"indexUUID",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Delete an index.
@param IndexUUID $indexUUID | [
"Delete",
"an",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L85-L90 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.resetIndex | public function resetIndex(IndexUUID $indexUUID)
{
$this->load();
parent::resetIndex($indexUUID);
$this->save();
} | php | public function resetIndex(IndexUUID $indexUUID)
{
$this->load();
parent::resetIndex($indexUUID);
$this->save();
} | [
"public",
"function",
"resetIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"resetIndex",
"(",
"$",
"indexUUID",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Reset the index.
@param IndexUUID $indexUUID | [
"Reset",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L97-L102 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.configureIndex | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
$this->load();
parent::configureIndex(
$indexUUID,
$config
);
$this->save();
} | php | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
$this->load();
parent::configureIndex(
$indexUUID,
$config
);
$this->save();
} | [
"public",
"function",
"configureIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
",",
"Config",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"configureIndex",
"(",
"$",
"indexUUID",
",",
"$",
"config",
")",
";",
"$",
"t... | Config the index.
@param IndexUUID $indexUUID
@param Config $config
@throws ResourceNotAvailableException | [
"Config",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L126-L136 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.addToken | public function addToken(Token $token)
{
$this->load();
parent::addToken($token);
$this->save();
} | php | public function addToken(Token $token)
{
$this->load();
parent::addToken($token);
$this->save();
} | [
"public",
"function",
"addToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"addToken",
"(",
"$",
"token",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Add token.
@param Token $token | [
"Add",
"token",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L143-L148 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.deleteToken | public function deleteToken(TokenUUID $tokenUUID)
{
$this->load();
parent::deleteToken($tokenUUID);
$this->save();
} | php | public function deleteToken(TokenUUID $tokenUUID)
{
$this->load();
parent::deleteToken($tokenUUID);
$this->save();
} | [
"public",
"function",
"deleteToken",
"(",
"TokenUUID",
"$",
"tokenUUID",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"parent",
"::",
"deleteToken",
"(",
"$",
"tokenUUID",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Delete token.
@param TokenUUID $tokenUUID | [
"Delete",
"token",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L155-L160 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.load | private function load()
{
if (!file_exists($this->filename)) {
return;
}
list($tokens, $indices) = unserialize(
file_get_contents(
$this->filename
)
);
$this->tokens = $tokens ?? [];
$this->indices = $indices ?? []... | php | private function load()
{
if (!file_exists($this->filename)) {
return;
}
list($tokens, $indices) = unserialize(
file_get_contents(
$this->filename
)
);
$this->tokens = $tokens ?? [];
$this->indices = $indices ?? []... | [
"private",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"return",
";",
"}",
"list",
"(",
"$",
"tokens",
",",
"$",
"indices",
")",
"=",
"unserialize",
"(",
"file_get_contents",
"(... | Load. | [
"Load",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L187-L201 |
apisearch-io/php-client | App/DiskAppRepository.php | DiskAppRepository.save | private function save()
{
file_put_contents(
$this->filename,
serialize([
$this->tokens,
$this->indices,
])
);
$this->tokens = [];
$this->indices = [];
} | php | private function save()
{
file_put_contents(
$this->filename,
serialize([
$this->tokens,
$this->indices,
])
);
$this->tokens = [];
$this->indices = [];
} | [
"private",
"function",
"save",
"(",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"filename",
",",
"serialize",
"(",
"[",
"$",
"this",
"->",
"tokens",
",",
"$",
"this",
"->",
"indices",
",",
"]",
")",
")",
";",
"$",
"this",
"->",
"tokens",
... | Save. | [
"Save",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/DiskAppRepository.php#L206-L217 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.getIndices | public function getIndices(): array
{
$appId = $this->getAppKey();
$result = [];
foreach ($this->indices as $index => $_) {
if (false !== preg_match("/(?P<app_id>[^_]+)\_(?P<id>[\S]+)/", $index, $matches)) {
if (!empty($appId) && $matches['app_id'] !== $appId) {
... | php | public function getIndices(): array
{
$appId = $this->getAppKey();
$result = [];
foreach ($this->indices as $index => $_) {
if (false !== preg_match("/(?P<app_id>[^_]+)\_(?P<id>[\S]+)/", $index, $matches)) {
if (!empty($appId) && $matches['app_id'] !== $appId) {
... | [
"public",
"function",
"getIndices",
"(",
")",
":",
"array",
"{",
"$",
"appId",
"=",
"$",
"this",
"->",
"getAppKey",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"indices",
"as",
"$",
"index",
"=>",
"$",
"_"... | Get indices.
@return Index[] | [
"Get",
"indices",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L52-L74 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.createIndex | public function createIndex(
IndexUUID $indexUUID,
Config $config
) {
if (array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceExistsException::indexExists();
}
$this->indices[$this->getIndexKey($indexUUID)] = [
'config' =... | php | public function createIndex(
IndexUUID $indexUUID,
Config $config
) {
if (array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceExistsException::indexExists();
}
$this->indices[$this->getIndexKey($indexUUID)] = [
'config' =... | [
"public",
"function",
"createIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
",",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"indexUUID",
")",
",",
"$",
"this",
"->",
"indices",
")",
")"... | Create an index.
@param IndexUUID $indexUUID
@param Config $config
@throws ResourceExistsException | [
"Create",
"an",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L84-L97 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.deleteIndex | public function deleteIndex(IndexUUID $indexUUID)
{
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
unset($this->indices[$this->getIndexKey($indexUUID)... | php | public function deleteIndex(IndexUUID $indexUUID)
{
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
unset($this->indices[$this->getIndexKey($indexUUID)... | [
"public",
"function",
"deleteIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"indexUUID",
")",
",",
"$",
"this",
"->",
"indices",
")",
")",
"{",
"throw",
"Resource... | Delete an index.
@param IndexUUID $indexUUID | [
"Delete",
"an",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L104-L111 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.resetIndex | public function resetIndex(IndexUUID $indexUUID)
{
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
$this->indices[$this->getIndexKey($indexUUID)]['was_... | php | public function resetIndex(IndexUUID $indexUUID)
{
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
$this->indices[$this->getIndexKey($indexUUID)]['was_... | [
"public",
"function",
"resetIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"indexUUID",
")",
",",
"$",
"this",
"->",
"indices",
")",
")",
"{",
"throw",
"ResourceN... | Reset the index.
@param IndexUUID $indexUUID | [
"Reset",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L118-L125 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.checkIndex | public function checkIndex(IndexUUID $indexUUID): bool
{
return array_key_exists($this->getIndexKey($indexUUID), $this->indices);
} | php | public function checkIndex(IndexUUID $indexUUID): bool
{
return array_key_exists($this->getIndexKey($indexUUID), $this->indices);
} | [
"public",
"function",
"checkIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
":",
"bool",
"{",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"indexUUID",
")",
",",
"$",
"this",
"->",
"indices",
")",
";",
"}"
] | Checks the index.
@param IndexUUID $indexUUID
@return bool | [
"Checks",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L134-L137 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.configureIndex | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
$this->indices... | php | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
if (!array_key_exists($this->getIndexKey($indexUUID), $this->indices)) {
throw ResourceNotAvailableException::indexNotAvailable('Index not available in InMemoryRepository');
}
$this->indices... | [
"public",
"function",
"configureIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
",",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"indexUUID",
")",
",",
"$",
"this",
"->",
"indices",
... | Config the index.
@param IndexUUID $indexUUID
@param Config $config
@throws ResourceNotAvailableException | [
"Config",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L147-L156 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.addToken | public function addToken(Token $token)
{
$this->tokens[$this->getAppKey()][$token->getTokenUUID()->composeUUID()] = $token;
} | php | public function addToken(Token $token)
{
$this->tokens[$this->getAppKey()][$token->getTokenUUID()->composeUUID()] = $token;
} | [
"public",
"function",
"addToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"tokens",
"[",
"$",
"this",
"->",
"getAppKey",
"(",
")",
"]",
"[",
"$",
"token",
"->",
"getTokenUUID",
"(",
")",
"->",
"composeUUID",
"(",
")",
"]",
"=",
"$"... | Add token.
@param Token $token | [
"Add",
"token",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L163-L166 |
apisearch-io/php-client | App/InMemoryAppRepository.php | InMemoryAppRepository.getAppKey | private function getAppKey(): string
{
$appUUID = $this
->getRepositoryReference()
->getAppUUID();
return $appUUID instanceof AppUUID
? $appUUID->getId()
: '';
} | php | private function getAppKey(): string
{
$appUUID = $this
->getRepositoryReference()
->getAppUUID();
return $appUUID instanceof AppUUID
? $appUUID->getId()
: '';
} | [
"private",
"function",
"getAppKey",
"(",
")",
":",
"string",
"{",
"$",
"appUUID",
"=",
"$",
"this",
"->",
"getRepositoryReference",
"(",
")",
"->",
"getAppUUID",
"(",
")",
";",
"return",
"$",
"appUUID",
"instanceof",
"AppUUID",
"?",
"$",
"appUUID",
"->",
... | Get app position by credentials.
@return string | [
"Get",
"app",
"position",
"by",
"credentials",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/InMemoryAppRepository.php#L213-L222 |
apisearch-io/php-client | Repository/InMemoryRepository.php | InMemoryRepository.query | public function query(
Query $query,
array $parameters = []
): Result {
$resultingItems = $this->items[$this->getIndexKey()] ?? [];
if (!empty($query->getFilters())) {
foreach ($query->getFilters() as $filter) {
if (Filter::TYPE_QUERY === $filter->getFilt... | php | public function query(
Query $query,
array $parameters = []
): Result {
$resultingItems = $this->items[$this->getIndexKey()] ?? [];
if (!empty($query->getFilters())) {
foreach ($query->getFilters() as $filter) {
if (Filter::TYPE_QUERY === $filter->getFilt... | [
"public",
"function",
"query",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
":",
"Result",
"{",
"$",
"resultingItems",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"this",
"->",
"getIndexKey",
"(",
")",
"]",
"??",
... | 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/InMemoryRepository.php#L46-L85 |
apisearch-io/php-client | Repository/InMemoryRepository.php | InMemoryRepository.flushItems | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
foreach ($itemsToUpdate as $itemToUpdate) {
$this->items[$this->getIndexKey()][$itemToUpdate->getUUID()->composeUUID()] = $itemToUpdate;
}
foreach ($itemsToDelete as $itemToDelete) {
... | php | protected function flushItems(
array $itemsToUpdate,
array $itemsToDelete
) {
foreach ($itemsToUpdate as $itemToUpdate) {
$this->items[$this->getIndexKey()][$itemToUpdate->getUUID()->composeUUID()] = $itemToUpdate;
}
foreach ($itemsToDelete as $itemToDelete) {
... | [
"protected",
"function",
"flushItems",
"(",
"array",
"$",
"itemsToUpdate",
",",
"array",
"$",
"itemsToDelete",
")",
"{",
"foreach",
"(",
"$",
"itemsToUpdate",
"as",
"$",
"itemToUpdate",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"this",
"->",
"getInde... | Flush items.
@param Item[] $itemsToUpdate
@param ItemUUID[] $itemsToDelete | [
"Flush",
"items",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/InMemoryRepository.php#L116-L127 |
apisearch-io/php-client | Model/ItemUUID.php | ItemUUID.createByComposedUUID | public static function createByComposedUUID(string $composedUUID): self
{
$parts = explode('~', $composedUUID);
if (2 !== count($parts)) {
throw InvalidFormatException::composedItemUUIDNotValid($composedUUID);
}
return new self($parts[0], $parts[1]);
} | php | public static function createByComposedUUID(string $composedUUID): self
{
$parts = explode('~', $composedUUID);
if (2 !== count($parts)) {
throw InvalidFormatException::composedItemUUIDNotValid($composedUUID);
}
return new self($parts[0], $parts[1]);
} | [
"public",
"static",
"function",
"createByComposedUUID",
"(",
"string",
"$",
"composedUUID",
")",
":",
"self",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'~'",
",",
"$",
"composedUUID",
")",
";",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"parts",
")",
")"... | Create by composed uuid.
@param string $composedUUID
@return ItemUUID
@throws InvalidFormatException | [
"Create",
"by",
"composed",
"uuid",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/ItemUUID.php#L62-L70 |
apisearch-io/php-client | Http/RetryMap.php | RetryMap.addRetry | public function addRetry(Retry $retry)
{
$this->retries[$retry->getUrl().'~~'.$retry->getMethod()] = $retry;
} | php | public function addRetry(Retry $retry)
{
$this->retries[$retry->getUrl().'~~'.$retry->getMethod()] = $retry;
} | [
"public",
"function",
"addRetry",
"(",
"Retry",
"$",
"retry",
")",
"{",
"$",
"this",
"->",
"retries",
"[",
"$",
"retry",
"->",
"getUrl",
"(",
")",
".",
"'~~'",
".",
"$",
"retry",
"->",
"getMethod",
"(",
")",
"]",
"=",
"$",
"retry",
";",
"}"
] | Add retry.
@param Retry $retry | [
"Add",
"retry",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/RetryMap.php#L35-L38 |
apisearch-io/php-client | Http/RetryMap.php | RetryMap.createFromArray | public static function createFromArray(array $data): RetryMap
{
$retryMap = new RetryMap();
foreach ($data as $entry) {
$retryMap->addRetry(Retry::createFromArray($entry));
}
return $retryMap;
} | php | public static function createFromArray(array $data): RetryMap
{
$retryMap = new RetryMap();
foreach ($data as $entry) {
$retryMap->addRetry(Retry::createFromArray($entry));
}
return $retryMap;
} | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"data",
")",
":",
"RetryMap",
"{",
"$",
"retryMap",
"=",
"new",
"RetryMap",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"$",
"retryMap",
"->",
"addRetry... | Create from array.
@param array $data
@return RetryMap | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/RetryMap.php#L47-L55 |
apisearch-io/php-client | Http/RetryMap.php | RetryMap.getRetry | public function getRetry(
string $url,
string $method
): ? Retry {
$url = trim(trim(strtolower($url)), '/');
$method = trim(strtolower($method));
if (isset($this->retries[$url.'~~'.$method])) {
return $this->retries[$url.'~~'.$method];
}
if (isse... | php | public function getRetry(
string $url,
string $method
): ? Retry {
$url = trim(trim(strtolower($url)), '/');
$method = trim(strtolower($method));
if (isset($this->retries[$url.'~~'.$method])) {
return $this->retries[$url.'~~'.$method];
}
if (isse... | [
"public",
"function",
"getRetry",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"method",
")",
":",
"?",
"Retry",
"{",
"$",
"url",
"=",
"trim",
"(",
"trim",
"(",
"strtolower",
"(",
"$",
"url",
")",
")",
",",
"'/'",
")",
";",
"$",
"method",
"=",
... | Check retry.
@param string $url
@param string $method
@return Retry|null | [
"Check",
"retry",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/RetryMap.php#L65-L89 |
apisearch-io/php-client | Model/Metadata.php | Metadata.fromMetadata | public static function fromMetadata(string $metadata): ? array
{
$values = [];
$splittedParts = explode('~~', $metadata);
foreach ($splittedParts as $part) {
$parts = explode('##', $part);
if (count($parts) > 1) {
$values[$parts[0]] = $parts[1];
... | php | public static function fromMetadata(string $metadata): ? array
{
$values = [];
$splittedParts = explode('~~', $metadata);
foreach ($splittedParts as $part) {
$parts = explode('##', $part);
if (count($parts) > 1) {
$values[$parts[0]] = $parts[1];
... | [
"public",
"static",
"function",
"fromMetadata",
"(",
"string",
"$",
"metadata",
")",
":",
"?",
"array",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"splittedParts",
"=",
"explode",
"(",
"'~~'",
",",
"$",
"metadata",
")",
";",
"foreach",
"(",
"$",
"s... | metadata format to array.
Allowed these formats
"simpletext"
"id##1234~~name##Marc
First format should cover both id and name with the desired value.
@param string $metadata
@return array|null | [
"metadata",
"format",
"to",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Model/Metadata.php#L59-L86 |
apisearch-io/php-client | Query/Range.php | Range.stringToArray | public static function stringToArray(string $string): array
{
list($from, $to) = explode(self::SEPARATOR, $string);
$from = empty($from)
? self::ZERO
: (is_numeric($from)
? (int) $from
: $from);
$to = empty($to)
? self::INF... | php | public static function stringToArray(string $string): array
{
list($from, $to) = explode(self::SEPARATOR, $string);
$from = empty($from)
? self::ZERO
: (is_numeric($from)
? (int) $from
: $from);
$to = empty($to)
? self::INF... | [
"public",
"static",
"function",
"stringToArray",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"list",
"(",
"$",
"from",
",",
"$",
"to",
")",
"=",
"explode",
"(",
"self",
"::",
"SEPARATOR",
",",
"$",
"string",
")",
";",
"$",
"from",
"=",
"e... | Get values given string.
@param string $string
@return array | [
"Get",
"values",
"given",
"string",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Range.php#L51-L67 |
apisearch-io/php-client | Query/Range.php | Range.arrayToString | public static function arrayToString(array $values): string
{
if (self::ZERO == $values[0]) {
$values[0] = '';
}
if (self::INFINITE == $values[1]) {
$values[1] = '';
}
return implode(self::SEPARATOR, $values);
} | php | public static function arrayToString(array $values): string
{
if (self::ZERO == $values[0]) {
$values[0] = '';
}
if (self::INFINITE == $values[1]) {
$values[1] = '';
}
return implode(self::SEPARATOR, $values);
} | [
"public",
"static",
"function",
"arrayToString",
"(",
"array",
"$",
"values",
")",
":",
"string",
"{",
"if",
"(",
"self",
"::",
"ZERO",
"==",
"$",
"values",
"[",
"0",
"]",
")",
"{",
"$",
"values",
"[",
"0",
"]",
"=",
"''",
";",
"}",
"if",
"(",
... | Get string given values.
@param array $values
@return string | [
"Get",
"string",
"given",
"values",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Range.php#L76-L86 |
apisearch-io/php-client | Query/Range.php | Range.createRanges | public static function createRanges(
int $from,
int $to,
int $incremental
): array {
$ranges = [];
while ($from < $to) {
$nextTo = $from + $incremental;
$ranges[] = $from.self::SEPARATOR.$nextTo;
$from = $nextTo;
}
return $... | php | public static function createRanges(
int $from,
int $to,
int $incremental
): array {
$ranges = [];
while ($from < $to) {
$nextTo = $from + $incremental;
$ranges[] = $from.self::SEPARATOR.$nextTo;
$from = $nextTo;
}
return $... | [
"public",
"static",
"function",
"createRanges",
"(",
"int",
"$",
"from",
",",
"int",
"$",
"to",
",",
"int",
"$",
"incremental",
")",
":",
"array",
"{",
"$",
"ranges",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"from",
"<",
"$",
"to",
")",
"{",
"$",
... | Create a set of ranges given a minimum, a maximum and an incremental.
@param int $from
@param int $to
@param int $incremental
@return array | [
"Create",
"a",
"set",
"of",
"ranges",
"given",
"a",
"minimum",
"a",
"maximum",
"and",
"an",
"incremental",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Query/Range.php#L97-L110 |
apisearch-io/php-client | Http/Http.php | Http.getApisearchHeaders | public static function getApisearchHeaders(RepositoryWithCredentials $repository): array
{
return [
self::APP_ID_HEADER => $repository->getAppUUID()->composeUUID(),
self::TOKEN_ID_HEADER => $repository->getTokenUUID()->composeUUID(),
];
} | php | public static function getApisearchHeaders(RepositoryWithCredentials $repository): array
{
return [
self::APP_ID_HEADER => $repository->getAppUUID()->composeUUID(),
self::TOKEN_ID_HEADER => $repository->getTokenUUID()->composeUUID(),
];
} | [
"public",
"static",
"function",
"getApisearchHeaders",
"(",
"RepositoryWithCredentials",
"$",
"repository",
")",
":",
"array",
"{",
"return",
"[",
"self",
"::",
"APP_ID_HEADER",
"=>",
"$",
"repository",
"->",
"getAppUUID",
"(",
")",
"->",
"composeUUID",
"(",
")"... | Get common query values.
@param RepositoryWithCredentials $repository
@return string[] | [
"Get",
"common",
"query",
"values",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/Http.php#L67-L73 |
apisearch-io/php-client | Geo/Polygon.php | Polygon.fromFilterArray | public static function fromFilterArray(array $array): LocationRange
{
$coordinates = array_map(function (array $coordinate) {
return Coordinate::createFromArray($coordinate);
}, $array['coordinates']);
return new Polygon($coordinates);
} | php | public static function fromFilterArray(array $array): LocationRange
{
$coordinates = array_map(function (array $coordinate) {
return Coordinate::createFromArray($coordinate);
}, $array['coordinates']);
return new Polygon($coordinates);
} | [
"public",
"static",
"function",
"fromFilterArray",
"(",
"array",
"$",
"array",
")",
":",
"LocationRange",
"{",
"$",
"coordinates",
"=",
"array_map",
"(",
"function",
"(",
"array",
"$",
"coordinate",
")",
"{",
"return",
"Coordinate",
"::",
"createFromArray",
"(... | From filter array.
@param array $array
@return LocationRange | [
"From",
"filter",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Geo/Polygon.php#L61-L68 |
apisearch-io/php-client | Repository/RepositoryWithCredentials.php | RepositoryWithCredentials.setCredentials | public function setCredentials(
RepositoryReference $repositoryReference,
TokenUUID $tokenUUID
) {
$this->tokenUUID = $tokenUUID;
$this->setRepositoryReference($repositoryReference);
} | php | public function setCredentials(
RepositoryReference $repositoryReference,
TokenUUID $tokenUUID
) {
$this->tokenUUID = $tokenUUID;
$this->setRepositoryReference($repositoryReference);
} | [
"public",
"function",
"setCredentials",
"(",
"RepositoryReference",
"$",
"repositoryReference",
",",
"TokenUUID",
"$",
"tokenUUID",
")",
"{",
"$",
"this",
"->",
"tokenUUID",
"=",
"$",
"tokenUUID",
";",
"$",
"this",
"->",
"setRepositoryReference",
"(",
"$",
"repo... | Set credentials.
@param RepositoryReference $repositoryReference
@param TokenUUID $tokenUUID | [
"Set",
"credentials",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/RepositoryWithCredentials.php#L40-L46 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.addToken | public function addToken(Token $token)
{
$response = $this
->httpClient
->get(
sprintf('/%s/tokens', $this->getAppUUID()->getId()),
'put',
[],
$token->toArray(),
Http::getApisearchHeaders($this)
... | php | public function addToken(Token $token)
{
$response = $this
->httpClient
->get(
sprintf('/%s/tokens', $this->getAppUUID()->getId()),
'put',
[],
$token->toArray(),
Http::getApisearchHeaders($this)
... | [
"public",
"function",
"addToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/tokens'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"getId",
"(",
")",
... | Add token.
@param Token $token | [
"Add",
"token",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L38-L51 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.deleteToken | public function deleteToken(TokenUUID $tokenUUID)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens/%s',
$this->getAppUUID()->composeUUID(),
$tokenUUID->composeUUID()
),
... | php | public function deleteToken(TokenUUID $tokenUUID)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens/%s',
$this->getAppUUID()->composeUUID(),
$tokenUUID->composeUUID()
),
... | [
"public",
"function",
"deleteToken",
"(",
"TokenUUID",
"$",
"tokenUUID",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/tokens/%s'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"composeUUI... | Delete token.
@param TokenUUID $tokenUUID | [
"Delete",
"token",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L58-L75 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.getTokens | public function getTokens(): array
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens',
$this->getAppUUID()->getId()
),
'get',
[],
[],
Htt... | php | public function getTokens(): array
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens',
$this->getAppUUID()->getId()
),
'get',
[],
[],
Htt... | [
"public",
"function",
"getTokens",
"(",
")",
":",
"array",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/tokens'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"getId",
"(",
")",
")",
","... | Get tokens.
@return Token[] | [
"Get",
"tokens",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L82-L102 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.deleteTokens | public function deleteTokens()
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens',
$this->getAppUUID()->getId()
),
'delete',
[],
[],
Http... | php | public function deleteTokens()
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/tokens',
$this->getAppUUID()->getId()
),
'delete',
[],
[],
Http... | [
"public",
"function",
"deleteTokens",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/tokens'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"getId",
"(",
")",
")",
",",
"'delete'",... | Delete all tokens. | [
"Delete",
"all",
"tokens",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L107-L123 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.getIndices | public function getIndices(): array
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices',
$this->getAppUUID()->getId()
),
'get',
[],
[],
H... | php | public function getIndices(): array
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices',
$this->getAppUUID()->getId()
),
'get',
[],
[],
H... | [
"public",
"function",
"getIndices",
"(",
")",
":",
"array",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"getId",
"(",
")",
")",
"... | Get indices.
@return Index[] | [
"Get",
"indices",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L130-L153 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.deleteIndex | public function deleteIndex(IndexUUID $indexUUID)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$indexUUID->composeUUID()
),
... | php | public function deleteIndex(IndexUUID $indexUUID)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$indexUUID->composeUUID()
),
... | [
"public",
"function",
"deleteIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices/%s'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"composeUU... | Delete an index.
@param IndexUUID $indexUUID
@throws ResourceNotAvailableException | [
"Delete",
"an",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L191-L208 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.checkIndex | public function checkIndex(IndexUUID $indexUUID): bool
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$indexUUID->composeUUID()
),
... | php | public function checkIndex(IndexUUID $indexUUID): bool
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s',
$this->getAppUUID()->composeUUID(),
$indexUUID->composeUUID()
),
... | [
"public",
"function",
"checkIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
")",
":",
"bool",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices/%s'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"-... | Checks the index.
@param IndexUUID $indexUUID
@return bool | [
"Checks",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L243-L264 |
apisearch-io/php-client | App/HttpAppRepository.php | HttpAppRepository.configureIndex | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/configure',
$this->getAppUUID()->composeUUID(),
$indexUU... | php | public function configureIndex(
IndexUUID $indexUUID,
Config $config
) {
$response = $this
->httpClient
->get(
sprintf(
'/%s/indices/%s/configure',
$this->getAppUUID()->composeUUID(),
$indexUU... | [
"public",
"function",
"configureIndex",
"(",
"IndexUUID",
"$",
"indexUUID",
",",
"Config",
"$",
"config",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/indices/%s/configure'",
",",
"$",
"this",
"->",... | Config the index.
@param IndexUUID $indexUUID
@param Config $config
@throws ResourceNotAvailableException | [
"Config",
"the",
"index",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/App/HttpAppRepository.php#L274-L297 |
apisearch-io/php-client | Repository/Repository.php | Repository.addItem | public function addItem(Item $item)
{
$itemUUID = $item->composeUUID();
$this->elementsToUpdate[$itemUUID] = $item;
unset($this->elementsToDelete[$itemUUID]);
} | php | public function addItem(Item $item)
{
$itemUUID = $item->composeUUID();
$this->elementsToUpdate[$itemUUID] = $item;
unset($this->elementsToDelete[$itemUUID]);
} | [
"public",
"function",
"addItem",
"(",
"Item",
"$",
"item",
")",
"{",
"$",
"itemUUID",
"=",
"$",
"item",
"->",
"composeUUID",
"(",
")",
";",
"$",
"this",
"->",
"elementsToUpdate",
"[",
"$",
"itemUUID",
"]",
"=",
"$",
"item",
";",
"unset",
"(",
"$",
... | Generate item document.
@param Item $item | [
"Generate",
"item",
"document",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/Repository.php#L67-L73 |
apisearch-io/php-client | Repository/Repository.php | Repository.deleteItem | public function deleteItem(ItemUUID $uuid)
{
$itemUUID = $uuid->composeUUID();
$this->elementsToDelete[$itemUUID] = $uuid;
unset($this->elementsToUpdate[$itemUUID]);
} | php | public function deleteItem(ItemUUID $uuid)
{
$itemUUID = $uuid->composeUUID();
$this->elementsToDelete[$itemUUID] = $uuid;
unset($this->elementsToUpdate[$itemUUID]);
} | [
"public",
"function",
"deleteItem",
"(",
"ItemUUID",
"$",
"uuid",
")",
"{",
"$",
"itemUUID",
"=",
"$",
"uuid",
"->",
"composeUUID",
"(",
")",
";",
"$",
"this",
"->",
"elementsToDelete",
"[",
"$",
"itemUUID",
"]",
"=",
"$",
"uuid",
";",
"unset",
"(",
... | Delete item document by uuid.
@param ItemUUID $uuid | [
"Delete",
"item",
"document",
"by",
"uuid",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/Repository.php#L92-L97 |
apisearch-io/php-client | Repository/Repository.php | Repository.flush | public function flush(
int $bulkNumber = 500,
bool $skipIfLess = false
) {
if (
$skipIfLess &&
count($this->elementsToUpdate) < $bulkNumber
) {
return;
}
$offset = 0;
try {
while (true) {
$items... | php | public function flush(
int $bulkNumber = 500,
bool $skipIfLess = false
) {
if (
$skipIfLess &&
count($this->elementsToUpdate) < $bulkNumber
) {
return;
}
$offset = 0;
try {
while (true) {
$items... | [
"public",
"function",
"flush",
"(",
"int",
"$",
"bulkNumber",
"=",
"500",
",",
"bool",
"$",
"skipIfLess",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"skipIfLess",
"&&",
"count",
"(",
"$",
"this",
"->",
"elementsToUpdate",
")",
"<",
"$",
"bulkNumber",
")",... | Flush all.
This flush can be avoided if not enough items have been generated by
setting $skipIfLess = true
@param int $bulkNumber
@param bool $skipIfLess
@throws ResourceNotAvailableException
@throws Exception | [
"Flush",
"all",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Repository/Repository.php#L123-L164 |
apisearch-io/php-client | Result/Aggregations.php | Aggregations.hasNotEmptyAggregation | public function hasNotEmptyAggregation(string $name): bool
{
return
!is_null($this->getAggregation($name)) &&
!$this
->getAggregation($name)
->isEmpty();
} | php | public function hasNotEmptyAggregation(string $name): bool
{
return
!is_null($this->getAggregation($name)) &&
!$this
->getAggregation($name)
->isEmpty();
} | [
"public",
"function",
"hasNotEmptyAggregation",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"return",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getAggregation",
"(",
"$",
"name",
")",
")",
"&&",
"!",
"$",
"this",
"->",
"getAggregation",
"(",
"$",
... | Return if the needed aggregation exists and if is not empty.
@param string $name
@return bool | [
"Return",
"if",
"the",
"needed",
"aggregation",
"exists",
"and",
"if",
"is",
"not",
"empty",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregations.php#L94-L101 |
apisearch-io/php-client | Result/Aggregations.php | Aggregations.toArray | public function toArray(): array
{
return array_filter([
'aggregations' => array_map(function (Aggregation $aggregation) {
return $aggregation->toArray();
}, $this->getAggregations()),
'total_elements' => $this->getTotalElements(),
]);
} | php | public function toArray(): array
{
return array_filter([
'aggregations' => array_map(function (Aggregation $aggregation) {
return $aggregation->toArray();
}, $this->getAggregations()),
'total_elements' => $this->getTotalElements(),
]);
} | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'aggregations'",
"=>",
"array_map",
"(",
"function",
"(",
"Aggregation",
"$",
"aggregation",
")",
"{",
"return",
"$",
"aggregation",
"->",
"toArray",
"(",
")",... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregations.php#L133-L141 |
apisearch-io/php-client | Result/Aggregations.php | Aggregations.createFromArray | public static function createFromArray(array $array): self
{
$aggregations = new self(
$array['total_elements'] ?? 0
);
if (isset($array['aggregations'])) {
foreach ($array['aggregations'] as $aggregationName => $aggregation) {
$aggregations->addAggre... | php | public static function createFromArray(array $array): self
{
$aggregations = new self(
$array['total_elements'] ?? 0
);
if (isset($array['aggregations'])) {
foreach ($array['aggregations'] as $aggregationName => $aggregation) {
$aggregations->addAggre... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"$",
"aggregations",
"=",
"new",
"self",
"(",
"$",
"array",
"[",
"'total_elements'",
"]",
"??",
"0",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"array",
... | Create from array.
@param array $array
@return self | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregations.php#L150-L166 |
apisearch-io/php-client | Http/TCPClient.php | TCPClient.get | public function get(
string $url,
string $method,
array $query = [],
array $body = [],
array $server = []
): array {
$method = strtolower($method);
$requestParts = $this->buildRequestParts(
$url,
$query,
$body,
$... | php | public function get(
string $url,
string $method,
array $query = [],
array $body = [],
array $server = []
): array {
$method = strtolower($method);
$requestParts = $this->buildRequestParts(
$url,
$query,
$body,
$... | [
"public",
"function",
"get",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"method",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"server",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
... | Get a response given some parameters.
Return an array with the status code and the body.
@param string $url
@param string $method
@param array $query
@param array $body
@param array $server
@return array
@throws ConnectionException | [
"Get",
"a",
"response",
"given",
"some",
"parameters",
".",
"Return",
"an",
"array",
"with",
"the",
"status",
"code",
"and",
"the",
"body",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/TCPClient.php#L77-L107 |
apisearch-io/php-client | Http/TCPClient.php | TCPClient.tryRequest | private function tryRequest(
callable $callable,
?Retry $retry
): array {
$tries = $retry instanceof Retry
? $retry->getRetries()
: 0;
while (true) {
try {
return $callable();
} catch (\Exception $e) {
i... | php | private function tryRequest(
callable $callable,
?Retry $retry
): array {
$tries = $retry instanceof Retry
? $retry->getRetries()
: 0;
while (true) {
try {
return $callable();
} catch (\Exception $e) {
i... | [
"private",
"function",
"tryRequest",
"(",
"callable",
"$",
"callable",
",",
"?",
"Retry",
"$",
"retry",
")",
":",
"array",
"{",
"$",
"tries",
"=",
"$",
"retry",
"instanceof",
"Retry",
"?",
"$",
"retry",
"->",
"getRetries",
"(",
")",
":",
"0",
";",
"w... | Try connection and return result.
Retry n times this connection before returning response.
@param callable $callable
@param Retry|null $retry
@return array
@throws Exception | [
"Try",
"connection",
"and",
"return",
"result",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Http/TCPClient.php#L121-L140 |
apisearch-io/php-client | Result/Aggregation.php | Aggregation.addCounter | public function addCounter(
string $name,
int $counter
) {
if (0 == $counter) {
return;
}
$counterInstance = Counter::createByActiveElements(
$name,
$counter,
$this->activeElements
);
if (!$counterInstance inst... | php | public function addCounter(
string $name,
int $counter
) {
if (0 == $counter) {
return;
}
$counterInstance = Counter::createByActiveElements(
$name,
$counter,
$this->activeElements
);
if (!$counterInstance inst... | [
"public",
"function",
"addCounter",
"(",
"string",
"$",
"name",
",",
"int",
"$",
"counter",
")",
"{",
"if",
"(",
"0",
"==",
"$",
"counter",
")",
"{",
"return",
";",
"}",
"$",
"counterInstance",
"=",
"Counter",
"::",
"createByActiveElements",
"(",
"$",
... | Add aggregation counter.
@param string $name
@param int $counter | [
"Add",
"aggregation",
"counter",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregation.php#L100-L138 |
apisearch-io/php-client | Result/Aggregation.php | Aggregation.getActiveElements | public function getActiveElements(): array
{
if (empty($this->activeElements)) {
return [];
}
if (Filter::MUST_ALL_WITH_LEVELS === $this->applicationType) {
$value = [array_reduce(
$this->activeElements,
function ($carry, $counter) {
... | php | public function getActiveElements(): array
{
if (empty($this->activeElements)) {
return [];
}
if (Filter::MUST_ALL_WITH_LEVELS === $this->applicationType) {
$value = [array_reduce(
$this->activeElements,
function ($carry, $counter) {
... | [
"public",
"function",
"getActiveElements",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"activeElements",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"Filter",
"::",
"MUST_ALL_WITH_LEVELS",
"===",
"$",
"this",
"-... | Get active elements.
@return array | [
"Get",
"active",
"elements",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregation.php#L217-L246 |
apisearch-io/php-client | Result/Aggregation.php | Aggregation.cleanCountersByLevel | public function cleanCountersByLevel()
{
foreach ($this->counters as $pos => $counter) {
if ($counter->getLevel() !== $this->highestActiveLevel + 1) {
unset($this->counters[$pos]);
}
}
} | php | public function cleanCountersByLevel()
{
foreach ($this->counters as $pos => $counter) {
if ($counter->getLevel() !== $this->highestActiveLevel + 1) {
unset($this->counters[$pos]);
}
}
} | [
"public",
"function",
"cleanCountersByLevel",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"counters",
"as",
"$",
"pos",
"=>",
"$",
"counter",
")",
"{",
"if",
"(",
"$",
"counter",
"->",
"getLevel",
"(",
")",
"!==",
"$",
"this",
"->",
"highestActiv... | Clean results by level and remove all levels higher than the lowest. | [
"Clean",
"results",
"by",
"level",
"and",
"remove",
"all",
"levels",
"higher",
"than",
"the",
"lowest",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregation.php#L251-L258 |
apisearch-io/php-client | Result/Aggregation.php | Aggregation.toArray | public function toArray(): array
{
return array_filter([
'name' => $this->name,
'counters' => array_values(array_map(function (Counter $counter) {
return $counter->toArray();
}, $this->counters)),
'application_type' => Filter::AT_LEAST_ONE === ... | php | public function toArray(): array
{
return array_filter([
'name' => $this->name,
'counters' => array_values(array_map(function (Counter $counter) {
return $counter->toArray();
}, $this->counters)),
'application_type' => Filter::AT_LEAST_ONE === ... | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'counters'",
"=>",
"array_values",
"(",
"array_map",
"(",
"function",
"(",
"Counter",
"$",
"counter",
")",
... | To array.
@return array | [
"To",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregation.php#L292-L320 |
apisearch-io/php-client | Result/Aggregation.php | Aggregation.createFromArray | public static function createFromArray(array $array): self
{
$activeElements = [];
foreach (($array['active_elements'] ?? []) as $activeElement) {
$activeElements[] = is_array($activeElement)
? Counter::createFromArray($activeElement)
: $activeElement;
... | php | public static function createFromArray(array $array): self
{
$activeElements = [];
foreach (($array['active_elements'] ?? []) as $activeElement) {
$activeElements[] = is_array($activeElement)
? Counter::createFromArray($activeElement)
: $activeElement;
... | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"array",
")",
":",
"self",
"{",
"$",
"activeElements",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"$",
"array",
"[",
"'active_elements'",
"]",
"??",
"[",
"]",
")",
"as",
"$",
"activeEl... | Create from array.
@param array $array
@return self | [
"Create",
"from",
"array",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/Result/Aggregation.php#L329-L355 |
apisearch-io/php-client | User/HttpUserRepository.php | HttpUserRepository.addInteraction | public function addInteraction(Interaction $interaction)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/interactions',
$this->getAppUUID()->composeUUID()
),
'post',
[],
... | php | public function addInteraction(Interaction $interaction)
{
$response = $this
->httpClient
->get(
sprintf(
'/%s/interactions',
$this->getAppUUID()->composeUUID()
),
'post',
[],
... | [
"public",
"function",
"addInteraction",
"(",
"Interaction",
"$",
"interaction",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"sprintf",
"(",
"'/%s/interactions'",
",",
"$",
"this",
"->",
"getAppUUID",
"(",
")",
"->",
"... | Add interaction.
@param Interaction $interaction | [
"Add",
"interaction",
"."
] | train | https://github.com/apisearch-io/php-client/blob/a6ecdd6dcd80cf1d28f58f2a23cdab618addb37a/User/HttpUserRepository.php#L31-L47 |
palantirnet/the-build | src/TheBuild/ForeachKeyTask.php | ForeachKeyTask.main | public function main() {
$this->validate();
$this->callee->setTarget($this->target);
$this->callee->setInheritAll(true);
$this->callee->setInheritRefs(true);
// Extract matching keys from the properties array.
$keys = [];
$project = $this->getProject();
foreach ($project->getProperties... | php | public function main() {
$this->validate();
$this->callee->setTarget($this->target);
$this->callee->setInheritAll(true);
$this->callee->setInheritRefs(true);
// Extract matching keys from the properties array.
$keys = [];
$project = $this->getProject();
foreach ($project->getProperties... | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"this",
"->",
"callee",
"->",
"setTarget",
"(",
"$",
"this",
"->",
"target",
")",
";",
"$",
"this",
"->",
"callee",
"->",
"setInheritAll",
"(",
"true",
... | Copy properties. | [
"Copy",
"properties",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/ForeachKeyTask.php#L72-L107 |
palantirnet/the-build | src/TheBuild/CopyPropertiesTask.php | CopyPropertiesTask.main | public function main() {
$this->validate();
// Use either Project::setProperty() or Project::setNewProperty() based on
// whether we're overriding values or not.
$this->propertyMethod = $this->override ? 'setProperty' : 'setNewProperty';
$project = $this->getProject();
foreach ($project->getPr... | php | public function main() {
$this->validate();
// Use either Project::setProperty() or Project::setNewProperty() based on
// whether we're overriding values or not.
$this->propertyMethod = $this->override ? 'setProperty' : 'setNewProperty';
$project = $this->getProject();
foreach ($project->getPr... | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"// Use either Project::setProperty() or Project::setNewProperty() based on",
"// whether we're overriding values or not.",
"$",
"this",
"->",
"propertyMethod",
"=",
"$",
"this",
"-... | Copy properties. | [
"Copy",
"properties",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/CopyPropertiesTask.php#L49-L63 |
palantirnet/the-build | src/TheBuild/CopyPropertiesTask.php | CopyPropertiesTask.validate | public function validate() {
if (empty($this->fromPrefix)) {
throw new BuildException("fromPrefix attribute is required.", $this->location);
}
if (empty($this->toPrefix)) {
throw new BuildException("toPrefix attribute is required.", $this->location);
}
} | php | public function validate() {
if (empty($this->fromPrefix)) {
throw new BuildException("fromPrefix attribute is required.", $this->location);
}
if (empty($this->toPrefix)) {
throw new BuildException("toPrefix attribute is required.", $this->location);
}
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fromPrefix",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"fromPrefix attribute is required.\"",
",",
"$",
"this",
"->",
"location",
")",
";",
"}",
"if... | Verify that the required attributes are set. | [
"Verify",
"that",
"the",
"required",
"attributes",
"are",
"set",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/CopyPropertiesTask.php#L69-L77 |
palantirnet/the-build | src/TheBuild/SelectPropertyKeyTask.php | SelectPropertyKeyTask.main | public function main() {
$this->validate();
$project = $this->getProject();
if ($existing_value = $this->project->getProperty($this->propertyName)) {
$this->log("Using {$this->propertyName} = '{$existing_value}' (existing value)", Project::MSG_INFO);
return;
}
// Extract matching keys ... | php | public function main() {
$this->validate();
$project = $this->getProject();
if ($existing_value = $this->project->getProperty($this->propertyName)) {
$this->log("Using {$this->propertyName} = '{$existing_value}' (existing value)", Project::MSG_INFO);
return;
}
// Extract matching keys ... | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"project",
"=",
"$",
"this",
"->",
"getProject",
"(",
")",
";",
"if",
"(",
"$",
"existing_value",
"=",
"$",
"this",
"->",
"project",
"->",
"getProperty",
... | Copy properties. | [
"Copy",
"properties",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/SelectPropertyKeyTask.php#L57-L99 |
palantirnet/the-build | src/TheBuild/IncludeResourceTask.php | IncludeResourceTask.init | public function init() {
$mode = $this->getProject()->getProperty('includeresource.mode');
if (!is_null($mode)) {
$this->setMode($mode);
}
} | php | public function init() {
$mode = $this->getProject()->getProperty('includeresource.mode');
if (!is_null($mode)) {
$this->setMode($mode);
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"mode",
"=",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getProperty",
"(",
"'includeresource.mode'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"mode",
")",
")",
"{",
"$",
"this",
"->",
"... | Init tasks.
Inherits the mode from the project's includeresource.mode property. This
can be overridden by setting the "mode" attribute. | [
"Init",
"tasks",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/IncludeResourceTask.php#L42-L47 |
palantirnet/the-build | src/TheBuild/IncludeResourceTask.php | IncludeResourceTask.main | public function main() {
$this->validate();
// Remove existing destination first.
if ($this->dest->exists()) {
$this->log("Replacing existing resource '" . $this->dest->getPath() . "'");
if ($this->dest->delete(TRUE) === FALSE) {
throw new BuildException("Failed to delete existing dest... | php | public function main() {
$this->validate();
// Remove existing destination first.
if ($this->dest->exists()) {
$this->log("Replacing existing resource '" . $this->dest->getPath() . "'");
if ($this->dest->delete(TRUE) === FALSE) {
throw new BuildException("Failed to delete existing dest... | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"// Remove existing destination first.",
"if",
"(",
"$",
"this",
"->",
"dest",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Replacing exis... | Copy or link the resource. | [
"Copy",
"or",
"link",
"the",
"resource",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/IncludeResourceTask.php#L53-L75 |
palantirnet/the-build | src/TheBuild/IncludeResourceTask.php | IncludeResourceTask.validate | public function validate() {
if (!in_array($this->mode, ['symlink', 'copy'])) {
throw new BuildException("mode attribute must be either 'symlink' or 'copy'", $this->location);
}
if (empty($this->source) || empty($this->dest)) {
throw new BuildException("Both the 'source' and 'dest' attributes a... | php | public function validate() {
if (!in_array($this->mode, ['symlink', 'copy'])) {
throw new BuildException("mode attribute must be either 'symlink' or 'copy'", $this->location);
}
if (empty($this->source) || empty($this->dest)) {
throw new BuildException("Both the 'source' and 'dest' attributes a... | [
"public",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"mode",
",",
"[",
"'symlink'",
",",
"'copy'",
"]",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"mode attribute must be either 'symlink' or 'copy'\"... | Verify that the required attributes are set. | [
"Verify",
"that",
"the",
"required",
"attributes",
"are",
"set",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/IncludeResourceTask.php#L81-L89 |
palantirnet/the-build | src/TheBuild/Acquia/AcquiaTask.php | AcquiaTask.loadCredentials | protected function loadCredentials() {
if (empty($this->mail) || empty($this->key)) {
if (empty($this->credentialsFile)) {
$this->credentialsFile = new PhingFile($_SERVER['HOME'] . '/.acquia/cloudapi.conf');
}
if (!file_exists($this->credentialsFile) || !is_readable($this->credentialsFile... | php | protected function loadCredentials() {
if (empty($this->mail) || empty($this->key)) {
if (empty($this->credentialsFile)) {
$this->credentialsFile = new PhingFile($_SERVER['HOME'] . '/.acquia/cloudapi.conf');
}
if (!file_exists($this->credentialsFile) || !is_readable($this->credentialsFile... | [
"protected",
"function",
"loadCredentials",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mail",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"key",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"credentialsFile",
")",
")"... | Load the Acquia Cloud credentials from the cloudapi.conf JSON file.
@throws \IOException
@throws \NullPointerException | [
"Load",
"the",
"Acquia",
"Cloud",
"credentials",
"from",
"the",
"cloudapi",
".",
"conf",
"JSON",
"file",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/Acquia/AcquiaTask.php#L65-L85 |
palantirnet/the-build | src/TheBuild/Acquia/AcquiaTask.php | AcquiaTask.createRequest | protected function createRequest($path) {
$this->loadCredentials();
$uri = $this->endpoint . '/' . ltrim($path, '/');
$request = new HTTP_Request2($uri);
$request->setConfig('follow_redirects', TRUE);
$request->setAuth($this->mail, $this->key);
return $request;
} | php | protected function createRequest($path) {
$this->loadCredentials();
$uri = $this->endpoint . '/' . ltrim($path, '/');
$request = new HTTP_Request2($uri);
$request->setConfig('follow_redirects', TRUE);
$request->setAuth($this->mail, $this->key);
return $request;
} | [
"protected",
"function",
"createRequest",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"loadCredentials",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"endpoint",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"reque... | Build an HTTP request object against the Acquia Cloud API.
@param $path
@return HTTP_Request2 | [
"Build",
"an",
"HTTP",
"request",
"object",
"against",
"the",
"Acquia",
"Cloud",
"API",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/Acquia/AcquiaTask.php#L93-L103 |
palantirnet/the-build | src/TheBuild/Acquia/AcquiaTask.php | AcquiaTask.getApiResponseBody | protected function getApiResponseBody($path) {
$request = $this->createRequest($path);
$this->log('GET ' . $request->getUrl());
$response = $request->send();
return $response->getBody();
} | php | protected function getApiResponseBody($path) {
$request = $this->createRequest($path);
$this->log('GET ' . $request->getUrl());
$response = $request->send();
return $response->getBody();
} | [
"protected",
"function",
"getApiResponseBody",
"(",
"$",
"path",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'GET '",
".",
"$",
"request",
"->",
"getUrl",
"(",
")",
")... | Example of how to query the Acquia Cloud API.
@param $path
@return string
@throws \HTTP_Request2_Exception | [
"Example",
"of",
"how",
"to",
"query",
"the",
"Acquia",
"Cloud",
"API",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/Acquia/AcquiaTask.php#L112-L118 |
palantirnet/the-build | src/TheBuild/SelectOneTask.php | SelectOneTask.main | public function main() {
$this->validate();
$project = $this->getProject();
if ($existing_value = $this->project->getProperty($this->propertyName)) {
$this->log("Using {$this->propertyName} = '{$existing_value}' (existing value)", Project::MSG_INFO);
return;
}
$keys = array_map('t... | php | public function main() {
$this->validate();
$project = $this->getProject();
if ($existing_value = $this->project->getProperty($this->propertyName)) {
$this->log("Using {$this->propertyName} = '{$existing_value}' (existing value)", Project::MSG_INFO);
return;
}
$keys = array_map('t... | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"project",
"=",
"$",
"this",
"->",
"getProject",
"(",
")",
";",
"if",
"(",
"$",
"existing_value",
"=",
"$",
"this",
"->",
"project",
"->",
"getProperty",
... | Select menu. | [
"Select",
"menu",
"."
] | train | https://github.com/palantirnet/the-build/blob/5d38721bf14c2db482acc731c012e9c8ba248c7d/src/TheBuild/SelectOneTask.php#L58-L87 |
cartalyst/collections | src/Collection.php | Collection.first | public function first(Closure $callback = null, $default = null)
{
return count($this->items) > 0 ? reset($this->items) : null;
} | php | public function first(Closure $callback = null, $default = null)
{
return count($this->items) > 0 ? reset($this->items) : null;
} | [
"public",
"function",
"first",
"(",
"Closure",
"$",
"callback",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
"?",
"reset",
"(",
"$",
"this",
"->",
"items",
")",
":",
"... | Get the first item from the collection.
@param \Closure $callback
@param mixed $default
@return mixed|null | [
"Get",
"the",
"first",
"item",
"from",
"the",
"collection",
"."
] | train | https://github.com/cartalyst/collections/blob/1a457cac7689386ca0fa09ee13e12a2fc9e370c6/src/Collection.php#L88-L91 |
cartalyst/collections | src/Collection.php | Collection.lists | public function lists($value)
{
return array_map(function ($item) use ($value) {
return isset($item[$value]) ? $item[$value] : null;
}, $this->items);
} | php | public function lists($value)
{
return array_map(function ($item) use ($value) {
return isset($item[$value]) ? $item[$value] : null;
}, $this->items);
} | [
"public",
"function",
"lists",
"(",
"$",
"value",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"value",
")",
"{",
"return",
"isset",
"(",
"$",
"item",
"[",
"$",
"value",
"]",
")",
"?",
"$",
"item",
"["... | Get an array with the values of a given key.
@param string $value
@return array | [
"Get",
"an",
"array",
"with",
"the",
"values",
"of",
"a",
"given",
"key",
"."
] | train | https://github.com/cartalyst/collections/blob/1a457cac7689386ca0fa09ee13e12a2fc9e370c6/src/Collection.php#L157-L162 |
cartalyst/collections | src/Collection.php | Collection.pull | public function pull($key, $default = null)
{
$value = $this->offsetGet($key);
$this->offsetUnset($key);
return $value ?: $default;
} | php | public function pull($key, $default = null)
{
$value = $this->offsetGet($key);
$this->offsetUnset($key);
return $value ?: $default;
} | [
"public",
"function",
"pull",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"return",
"$",
... | Pulls an item from the collection.
@param mixed $key
@param mixed $default
@return mixed | [
"Pulls",
"an",
"item",
"from",
"the",
"collection",
"."
] | train | https://github.com/cartalyst/collections/blob/1a457cac7689386ca0fa09ee13e12a2fc9e370c6/src/Collection.php#L192-L199 |
cartalyst/collections | src/Collection.php | Collection.sum | public function sum($callback = null)
{
if (is_null($callback)) {
return array_sum($this->items);
}
return array_reduce($this->items, function ($result, $item) use ($callback) {
if (is_string($callback)) {
return $result += $item->{$callback}();
... | php | public function sum($callback = null)
{
if (is_null($callback)) {
return array_sum($this->items);
}
return array_reduce($this->items, function ($result, $item) use ($callback) {
if (is_string($callback)) {
return $result += $item->{$callback}();
... | [
"public",
"function",
"sum",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"array_sum",
"(",
"$",
"this",
"->",
"items",
")",
";",
"}",
"return",
"array_reduce",
"(",
"$",
"this",
... | Get the sum of the collection items.
@param mixed $callback
@return mixed | [
"Get",
"the",
"sum",
"of",
"the",
"collection",
"items",
"."
] | train | https://github.com/cartalyst/collections/blob/1a457cac7689386ca0fa09ee13e12a2fc9e370c6/src/Collection.php#L302-L315 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.render | public function render($view, $data = [], $mergeData = [])
{
if ($this->request()->ajax() && $this->request()->wantsJson()) {
return app()->call([$this, 'ajax']);
}
if ($action = $this->request()->get('action') and in_array($action, $this->actions)) {
if ($action == ... | php | public function render($view, $data = [], $mergeData = [])
{
if ($this->request()->ajax() && $this->request()->wantsJson()) {
return app()->call([$this, 'ajax']);
}
if ($action = $this->request()->get('action') and in_array($action, $this->actions)) {
if ($action == ... | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"mergeData",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"(",
")",
"->",
"ajax",
"(",
")",
"&&",
"$",
"this",
"->",
"request",
... | Process dataTables needed render output.
@param string $view
@param array $data
@param array $mergeData
@return mixed | [
"Process",
"dataTables",
"needed",
"render",
"output",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L155-L170 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.ajax | public function ajax()
{
$source = null;
if (method_exists($this, 'query')) {
$source = app()->call([$this, 'query']);
$source = $this->applyScopes($source);
}
/** @var \Yajra\DataTables\DataTableAbstract $dataTable */
$dataTable = app()->call([$this,... | php | public function ajax()
{
$source = null;
if (method_exists($this, 'query')) {
$source = app()->call([$this, 'query']);
$source = $this->applyScopes($source);
}
/** @var \Yajra\DataTables\DataTableAbstract $dataTable */
$dataTable = app()->call([$this,... | [
"public",
"function",
"ajax",
"(",
")",
"{",
"$",
"source",
"=",
"null",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'query'",
")",
")",
"{",
"$",
"source",
"=",
"app",
"(",
")",
"->",
"call",
"(",
"[",
"$",
"this",
",",
"'query'",
... | Display ajax response.
@return \Illuminate\Http\JsonResponse | [
"Display",
"ajax",
"response",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L187-L209 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.printColumns | protected function printColumns()
{
return is_array($this->printColumns) ? $this->toColumnsCollection($this->printColumns) : $this->getPrintColumnsFromBuilder();
} | php | protected function printColumns()
{
return is_array($this->printColumns) ? $this->toColumnsCollection($this->printColumns) : $this->getPrintColumnsFromBuilder();
} | [
"protected",
"function",
"printColumns",
"(",
")",
"{",
"return",
"is_array",
"(",
"$",
"this",
"->",
"printColumns",
")",
"?",
"$",
"this",
"->",
"toColumnsCollection",
"(",
"$",
"this",
"->",
"printColumns",
")",
":",
"$",
"this",
"->",
"getPrintColumnsFro... | Get printable columns.
@return array|string | [
"Get",
"printable",
"columns",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L240-L243 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.mapResponseToColumns | protected function mapResponseToColumns($columns, $type)
{
$transformer = new DataArrayTransformer;
return array_map(function ($row) use ($columns, $type, $transformer) {
return $transformer->transform($row, $columns, $type);
}, $this->getAjaxResponseData());
} | php | protected function mapResponseToColumns($columns, $type)
{
$transformer = new DataArrayTransformer;
return array_map(function ($row) use ($columns, $type, $transformer) {
return $transformer->transform($row, $columns, $type);
}, $this->getAjaxResponseData());
} | [
"protected",
"function",
"mapResponseToColumns",
"(",
"$",
"columns",
",",
"$",
"type",
")",
"{",
"$",
"transformer",
"=",
"new",
"DataArrayTransformer",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"row",
")",
"use",
"(",
"$",
"columns",
",",
"$... | Map ajax response to columns definition.
@param mixed $columns
@param string $type
@return array | [
"Map",
"ajax",
"response",
"to",
"columns",
"definition",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L302-L309 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.getAjaxResponseData | protected function getAjaxResponseData()
{
$this->request()->merge(['length' => -1]);
$response = app()->call([$this, 'ajax']);
$data = $response->getData(true);
return $data['data'];
} | php | protected function getAjaxResponseData()
{
$this->request()->merge(['length' => -1]);
$response = app()->call([$this, 'ajax']);
$data = $response->getData(true);
return $data['data'];
} | [
"protected",
"function",
"getAjaxResponseData",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"(",
")",
"->",
"merge",
"(",
"[",
"'length'",
"=>",
"-",
"1",
"]",
")",
";",
"$",
"response",
"=",
"app",
"(",
")",
"->",
"call",
"(",
"[",
"$",
"this",
... | Get decorated data as defined in datatables ajax response.
@return array | [
"Get",
"decorated",
"data",
"as",
"defined",
"in",
"datatables",
"ajax",
"response",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L316-L324 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.excel | public function excel()
{
$ext = '.' . strtolower($this->excelWriter);
return $this->buildExcelFile()->download($this->getFilename() . $ext, $this->excelWriter);
} | php | public function excel()
{
$ext = '.' . strtolower($this->excelWriter);
return $this->buildExcelFile()->download($this->getFilename() . $ext, $this->excelWriter);
} | [
"public",
"function",
"excel",
"(",
")",
"{",
"$",
"ext",
"=",
"'.'",
".",
"strtolower",
"(",
"$",
"this",
"->",
"excelWriter",
")",
";",
"return",
"$",
"this",
"->",
"buildExcelFile",
"(",
")",
"->",
"download",
"(",
"$",
"this",
"->",
"getFilename",
... | Export results to Excel file.
@return void | [
"Export",
"results",
"to",
"Excel",
"file",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L383-L388 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.exportColumns | private function exportColumns()
{
return is_array($this->exportColumns) ? $this->toColumnsCollection($this->exportColumns) : $this->getExportColumnsFromBuilder();
} | php | private function exportColumns()
{
return is_array($this->exportColumns) ? $this->toColumnsCollection($this->exportColumns) : $this->getExportColumnsFromBuilder();
} | [
"private",
"function",
"exportColumns",
"(",
")",
"{",
"return",
"is_array",
"(",
"$",
"this",
"->",
"exportColumns",
")",
"?",
"$",
"this",
"->",
"toColumnsCollection",
"(",
"$",
"this",
"->",
"exportColumns",
")",
":",
"$",
"this",
"->",
"getExportColumnsF... | Get export columns definition.
@return array|string | [
"Get",
"export",
"columns",
"definition",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L452-L455 |
yajra/laravel-datatables-buttons | src/Services/DataTable.php | DataTable.toColumnsCollection | private function toColumnsCollection(array $columns)
{
$collection = collect();
foreach ($columns as $column) {
if (isset($column['data'])) {
$column['title'] = $column['title'] ?? $column['data'];
$collection->push(new Column($column));
} else... | php | private function toColumnsCollection(array $columns)
{
$collection = collect();
foreach ($columns as $column) {
if (isset($column['data'])) {
$column['title'] = $column['title'] ?? $column['data'];
$collection->push(new Column($column));
} else... | [
"private",
"function",
"toColumnsCollection",
"(",
"array",
"$",
"columns",
")",
"{",
"$",
"collection",
"=",
"collect",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'data'"... | Convert array to collection of Column class.
@param array $columns
@return Collection | [
"Convert",
"array",
"to",
"collection",
"of",
"Column",
"class",
"."
] | train | https://github.com/yajra/laravel-datatables-buttons/blob/291c129ab9db63e5ec5353336181e8c6a95e3e19/src/Services/DataTable.php#L463-L479 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.