Fix Formatters::valueToString when is an array
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
009b2f2d53
commit
4c1a1a0af8
3 changed files with 28 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ class Formatters {
|
||||||
}
|
}
|
||||||
elseif(is_array($value))
|
elseif(is_array($value))
|
||||||
{
|
{
|
||||||
return self::toFluxArrayString($value);
|
return '[' . self::toFluxArrayString($value) . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,12 @@ class Group extends Base {
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return '|> group(columns: [' . Formatters::toFluxArrayString($this->columns) . '], mode: "' . $this->mode . '") ';
|
$array = Formatters::toFluxArrayString([
|
||||||
|
'columns' => $this->columns,
|
||||||
|
'mode' => $this->mode,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return '|> group(' . $array . ') ';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
21
tests/FormattersTest.php
Normal file
21
tests/FormattersTest.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Arendsen\FluxQueryBuilder\Formatters;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
final class FormattersTest extends TestCase {
|
||||||
|
|
||||||
|
public function testAssociativeArrayNested()
|
||||||
|
{
|
||||||
|
$array = [
|
||||||
|
'columns' => ['foo', 'bar'],
|
||||||
|
'mode' => 'by'
|
||||||
|
];
|
||||||
|
|
||||||
|
$expected = 'columns: ["foo", "bar"], mode: "by"';
|
||||||
|
|
||||||
|
$this->assertEquals($expected, Formatters::toFluxArrayString($array));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue