/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Traits/ParseResultTrait.php
37 строк
831 B
Alexei Shabalin
namespace updated
20 дек 2022, 15:20
20 дек 2022, 15:20
e4410bc
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb\Traits; trait ParseResultTrait { /** * @param object $result * @param array|null $properties * @param mixed $default * @return array|mixed|null */ protected function parseResult($result, $properties = null, $default = null) { $result = json_decode($result->serializeToJsonString(), true); $parsedResult = []; if (is_array($properties)) { foreach ($properties as $property) { $parsedResult[$property] = $result[$property] ?? null; } } else if (is_string($properties)) { $parsedResult = $result[$properties] ?? $default; } else { $parsedResult = $result; } return $parsedResult; } }