Skip to content

Commit f35e487

Browse files
committed
used bolt conversion functionality in parameterhelper
1 parent e692e72 commit f35e487

File tree

2 files changed

+443
-2
lines changed

2 files changed

+443
-2
lines changed

src/ParameterHelper.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
namespace Laudis\Neo4j;
1515

16+
use Bolt\structures\IStructure;
1617
use function count;
1718
use function gettype;
1819
use InvalidArgumentException;
1920
use function is_array;
2021
use function is_int;
2122
use function is_object;
2223
use function is_string;
24+
use Laudis\Neo4j\Contracts\BoltConvertibleInterface;
2325
use Laudis\Neo4j\Types\CypherList;
2426
use Laudis\Neo4j\Types\CypherMap;
2527
use stdClass;
@@ -65,12 +67,13 @@ public static function asMap(iterable $iterable): CypherMap
6567
/**
6668
* @param mixed $value
6769
*
68-
* @return iterable|scalar|stdClass|null
70+
* @return iterable|scalar|stdClass|null|IStructure
6971
*/
70-
public static function asParameter($value)
72+
public static function asParameter($value, bool $boltDriver = false)
7173
{
7274
return self::cypherMapToStdClass($value) ??
7375
self::emptySequenceToArray($value) ??
76+
self::convertBoltConvertibles($value, $boltDriver) ??
7477
self::filledIterableToArray($value) ??
7578
self::stringAbleToString($value) ??
7679
self::filterInvalidType($value);
@@ -191,4 +194,13 @@ private static function iterableToArray(iterable $value): array
191194

192195
return $tbr;
193196
}
197+
198+
private static function convertBoltConvertibles($value, bool $boltDriver): ?IStructure
199+
{
200+
if ($boltDriver && $value instanceof BoltConvertibleInterface) {
201+
return $value->convertToBolt();
202+
}
203+
204+
return null;
205+
}
194206
}

0 commit comments

Comments
 (0)