Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit 8d88f98

Browse files
committed
update doc
1 parent 5c16f0e commit 8d88f98

File tree

2 files changed

+41
-62
lines changed

2 files changed

+41
-62
lines changed
+41-53
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
# IteratableToNodeConverter
22

3-
**Important**: By default empty nodes get not serialized. NullNode forces null value serialization.
4-
5-
* ArrayNode (no elements)
6-
* BoolNode (null)
7-
* ObjectNode (no elements)
8-
* FloatNode (null)
9-
* IntNode (null)
10-
* StringNode (null)
11-
12-
This works recursive, which means theoretically a multidimensional array can lead into an empty string return.
13-
14-
Check the `allowSerializeEmpty` argument to prevent this if needed.
15-
16-
## Example
3+
## Without allowSerializeEmpty
174

185
```php
196
<?php
@@ -23,30 +10,32 @@ use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
2310
use Saxulum\ElasticSearchQueryBuilder\Node\ObjectNode;
2411

2512
$iteratableConverter = new IteratableToNodeConverter(new ScalarToNodeConverter());
26-
$test = $iteratableConverter->convert(['key' => [true, 1.234, 1, null, 'string', []]])->serialize(); // instanceof ObjectNode::class
27-
var_dump($test);
13+
$node = $iteratableConverter->convert([
14+
'key' => [
15+
true,
16+
1.234,
17+
1,
18+
null,
19+
'string',
20+
[]
21+
]
22+
]); // instanceof ObjectNode::class
23+
echo $node->json(true));
2824
```
2925

30-
Returns
31-
```
26+
```json
3227
{
33-
["key"]=>
34-
array(5) {
35-
[0]=>
36-
bool(true)
37-
[1]=>
38-
float(1.234)
39-
[2]=>
40-
int(1)
41-
[3]=>
42-
NULL
43-
[4]=>
44-
string(6) "string"
45-
}
28+
"key": [
29+
true,
30+
1.234,
31+
1,
32+
null,
33+
"string"
34+
]
4635
}
4736
```
4837

49-
## Example with allowSerializeEmpty
38+
## With allowSerializeEmpty
5039

5140
```php
5241
<?php
@@ -56,28 +45,27 @@ use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
5645
use Saxulum\ElasticSearchQueryBuilder\Node\ObjectNode;
5746

5847
$iteratableConverter = new IteratableToNodeConverter(new ScalarToNodeConverter());
59-
$test = $iteratableConverter->convert(['key' => [true, 1.234, 1, null, 'string', []]], '', true)->serialize(); // instanceof ObjectNode::class
60-
var_dump($test);
48+
$node = $iteratableConverter->convert([
49+
'key' => [
50+
true,
51+
1.234,
52+
1,
53+
null,
54+
'string',
55+
[]
56+
]
57+
], true); // instanceof ObjectNode::class
58+
echo $node->json(true));
6159
```
6260

63-
Returns
64-
```
61+
```json
6562
{
66-
["key"]=>
67-
array(6) {
68-
[0]=>
69-
bool(true)
70-
[1]=>
71-
float(1.234)
72-
[2]=>
73-
int(1)
74-
[3]=>
75-
NULL
76-
[4]=>
77-
string(6) "string"
78-
[5]=>
79-
array(0) {
80-
}
81-
}
63+
"key": [
64+
true,
65+
1.234,
66+
1,
67+
null,
68+
"string",
69+
[]
70+
]
8271
}
83-
```

doc/Converter/ScalarToNodeConverter.md

-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# ScalarToNodeConverter
22

3-
**Important**: By default empty nodes get not serialized. NullNode forces null value serialization.
4-
5-
* ArrayNode (no elements)
6-
* BoolNode (null)
7-
* ObjectNode (no elements)
8-
* FloatNode (null)
9-
* IntNode (null)
10-
* StringNode (null)
11-
123
Check the `allowSerializeEmpty` argument to prevent this if needed.
134

145
## Bool value

0 commit comments

Comments
 (0)