PHP Класс Alcaeus\MongoDbAdapter\TypeConverter

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
fromLegacy ( mixed $value ) : mixed Converts a legacy type to the new BSON type
isNumericArray ( array $array ) : boolean Helper method to find out if an array has numerical indexes
toLegacy ( mixed $value ) : mixed Converts a BSON type to the legacy types

Приватные методы

Метод Описание
convertBSONObjectToLegacy ( MongoDB\BSON\Type $value ) : mixed Converter method to convert a BSON object to its legacy type
ensureCorrectType ( array $array, boolean $wasObject = false ) : array | MongoDB\Model\BSONArray | MongoDB\Model\BSONDocument Converts all arrays with non-numeric keys to stdClass

Описание методов

fromLegacy() публичный статический метод

This method handles type conversion from ext-mongo to ext-mongodb: - For all types (MongoId, MongoDate, etc.) it returns the correct BSON object instance - For arrays and objects it iterates over properties and converts each item individually - For other types it returns the value unconverted
public static fromLegacy ( mixed $value ) : mixed
$value mixed
Результат mixed

isNumericArray() публичный статический метод

For performance reason, this method checks the first array index only. More thorough inspection of the array might be needed. Note: Returns true for empty arrays to preserve compatibility with empty lists.
public static isNumericArray ( array $array ) : boolean
$array array
Результат boolean

toLegacy() публичный статический метод

This method handles type conversion from ext-mongodb to ext-mongo: - For all instances of BSON\Type it returns an object of the corresponding legacy type (MongoId, MongoDate, etc.) - For arrays and objects it iterates over properties and converts each item individually - For other types it returns the value unconverted
public static toLegacy ( mixed $value ) : mixed
$value mixed
Результат mixed