Skip to content

Commit c586cb8

Browse files
documentation examples
1 parent 85f63cc commit c586cb8

19 files changed

+279
-327
lines changed

src/Helper/Esql/ChangePointCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function as(string $type_name, string $pvalue_name): ChangePointCommand
6262

6363
protected function renderInternal(): string
6464
{
65-
$key = $this->key ? " ON " . $this->format_id($this->key) : "";
65+
$key = $this->key ? " ON " . $this->formatId($this->key) : "";
6666
$names = ($this->type_name && $this->pvalue_name) ?
67-
" AS " . $this->format_id($this->type_name) . ", " .
68-
$this->format_id($this->pvalue_name)
67+
" AS " . $this->formatId($this->type_name) . ", " .
68+
$this->formatId($this->pvalue_name)
6969
: "";
7070
return "CHANGE_POINT " . $this->value . $key . $names;
7171
}

src/Helper/Esql/CompletionCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(EsqlBase $parent, array $prompt)
3333
throw new RuntimeException("Only one prompt is supported");
3434
}
3535
parent::__construct($parent);
36-
if ($this->is_named_argument_list($prompt)) {
36+
if ($this->isNamedArgumentList($prompt)) {
3737
$this->named_prompt = $prompt;
3838
}
3939
else {
@@ -62,12 +62,12 @@ protected function renderInternal(): string
6262
$with = ["inference_id" => $this->inference_id];
6363
if ($this->named_prompt) {
6464
return "COMPLETION " .
65-
$this->format_id(array_keys($this->named_prompt)[0]) . " = " .
66-
$this->format_id(array_values($this->named_prompt)[0]) .
65+
$this->formatId(array_keys($this->named_prompt)[0]) . " = " .
66+
$this->formatId(array_values($this->named_prompt)[0]) .
6767
" WITH " . json_encode($with);
6868
}
6969
else {
70-
return "COMPLETION " . $this->format_id($this->prompt) .
70+
return "COMPLETION " . $this->formatId($this->prompt) .
7171
" WITH " . json_encode($with);
7272
}
7373
}

src/Helper/Esql/DissectCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public function append_separator(string $separator): DissectCommand
4747
protected function renderInternal(): string
4848
{
4949
$sep = $this->separator ? " APPEND_SEPARATOR=" . json_encode($this->separator) : "";
50-
return "DISSECT " . $this->format_id($this->input) . " " . json_encode($this->pattern) . $sep;
50+
return "DISSECT " . $this->formatId($this->input) . " " . json_encode($this->pattern) . $sep;
5151
}
5252
}

src/Helper/Esql/DropCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(EsqlBase $parent, array $columns)
3232
protected function renderInternal(): string
3333
{
3434
return "DROP " . implode(
35-
", ", array_map(array($this, "format_id"), $this->columns)
35+
", ", array_map(array($this, "formatId"), $this->columns)
3636
);
3737
}
3838
}

src/Helper/Esql/EnrichCommand.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function on(string $match_field): EnrichCommand
6363
*/
6464
public function with(string ...$fields): EnrichCommand
6565
{
66-
if ($this->is_named_argument_list($fields)) {
66+
if ($this->isNamedArgumentList($fields)) {
6767
$this->named_fields = $fields;
6868
}
6969
else {
@@ -74,23 +74,17 @@ public function with(string ...$fields): EnrichCommand
7474

7575
protected function renderInternal(): string
7676
{
77-
$on = ($this->match_field != "") ? " ON " . $this->format_id($this->match_field) : "";
77+
$on = ($this->match_field != "") ? " ON " . $this->formatId($this->match_field) : "";
7878
$with = "";
7979
$items = [];
8080
if (sizeof($this->named_fields)) {
81-
$items = array_map(
82-
function(string $key): string {
83-
return $this->format_id($key) . " = " .
84-
$this->format_id($this->named_fields[$key]);
85-
},
86-
array_keys($this->named_fields)
87-
);
81+
$with = " WITH " . $this->formatKeyValues($this->named_fields);
8882
}
8983
else if (sizeof($this->fields)) {
90-
$items = array_map(fn($value): string => $this->format_id($value), $this->fields);
91-
}
92-
if (sizeof($items)) {
93-
$with = " WITH " . implode(", ", $items);
84+
$with = implode(
85+
", ",
86+
array_map(fn($value): string => $this->formatId($value), $this->fields)
87+
);
9488
}
9589
return "ENRICH " . $this->policy . $on . $with;
9690
}

0 commit comments

Comments
 (0)