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

Latest commit

 

History

History
63 lines (42 loc) · 1.41 KB

ScalarToNodeConverter.md

File metadata and controls

63 lines (42 loc) · 1.41 KB

ScalarToNodeConverter

Check the allowSerializeEmpty argument to prevent this if needed.

Bool value

<?php

use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
use Saxulum\ElasticSearchQueryBuilder\Node\BoolNode;

$valueConverter = new ScalarToNodeConverter();
$valueConverter->convert(true); // instanceof BoolNode::class

Float value

<?php

use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
use Saxulum\ElasticSearchQueryBuilder\Node\FloatNode;

$valueConverter = new ScalarToNodeConverter();
$valueConverter->convert(1.234); // instanceof FloatNode::class

Int value

<?php

use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
use Saxulum\ElasticSearchQueryBuilder\Node\IntNode;

$valueConverter = new ScalarToNodeConverter();
$valueConverter->convert(1); // instanceof IntNode::class

Null value

<?php

use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
use Saxulum\ElasticSearchQueryBuilder\Node\NullNode;

$valueConverter = new ScalarToNodeConverter();
$valueConverter->convert(null); // instanceof NullNode::class

String value

<?php

use Saxulum\ElasticSearchQueryBuilder\Converter\ScalarToNodeConverter;
use Saxulum\ElasticSearchQueryBuilder\Node\StringNode;

$valueConverter = new ScalarToNodeConverter();
$valueConverter->convert('string'); // instanceof StringNode::class