private static function convertBSONObjectToLegacy(BSON\Type $value)
    {
        switch (true) {
            case $value instanceof BSON\ObjectID:
                return new \MongoId($value);
            case $value instanceof BSON\Binary:
                return new \MongoBinData($value);
            case $value instanceof BSON\Javascript:
                return new \MongoCode($value);
            case $value instanceof BSON\MaxKey:
                return new \MongoMaxKey();
            case $value instanceof BSON\MinKey:
                return new \MongoMinKey();
            case $value instanceof BSON\Regex:
                return new \MongoRegex($value);
            case $value instanceof BSON\Timestamp:
                return new \MongoTimestamp($value);
            case $value instanceof BSON\UTCDatetime:
                return new \MongoDate($value);
            case $value instanceof Model\BSONDocument:
            case $value instanceof Model\BSONArray:
                return array_map(
                    ['self', 'toLegacy'],
                    $value->getArrayCopy()
                );
            default:
                return $value;
        }
    }
private static function convertBSONObjectToLegacy(BSON\Type $value)
    {
        switch (true) {
            case $value instanceof BSON\ObjectID:
                return new \MongoId($value);
            case $value instanceof BSON\Binary:
                return new \MongoBinData($value);
            case $value instanceof BSON\Javascript:
                return new \MongoCode($value);
            case $value instanceof BSON\MaxKey:
                return new \MongoMaxKey();
            case $value instanceof BSON\MinKey:
                return new \MongoMinKey();
            case $value instanceof BSON\Regex:
                return new \MongoRegex($value);
            case $value instanceof BSON\Timestamp:
                return new \MongoTimestamp($value);
            case $value instanceof BSON\UTCDatetime:
                return new \MongoDate($value);
            case $value instanceof Model\BSONDocument:
            case $value instanceof Model\BSONArray:
                return array_map(
                    ['self', 'toLegacy'],
                    $value->getArrayCopy()
                );
            default:
                return $value;
        }
    }
private static function convertBSONObjectToLegacy ( BSON \ Type $ value ) { switch ( true ) { case $ value instanceof BSON \ ObjectID : return new \ MongoId ( $ value ) ; case $ value instanceof BSON \ Binary : return new \ MongoBinData ( $ value ) ; case $ value instanceof BSON \ Javascript : return new \ MongoCode ( $ value ) ; case $ value instanceof BSON \ MaxKey : return new \ MongoMaxKey ( ) ; case $ value instanceof BSON \ MinKey : return new \ MongoMinKey ( ) ; case $ value instanceof BSON \ Regex : return new \ MongoRegex ( $ value ) ; case $ value instanceof BSON \ Timestamp : return new \ MongoTimestamp ( $ value ) ; case $ value instanceof BSON \ UTCDatetime : return new \ MongoDate ( $ value ) ; case $ value instanceof Model \ BSONDocument : case $ value instanceof Model \ BSONArray : return array_map ( [ 'self' , 'toLegacy' ] , $ value -> getArrayCopy ( ) ) ; default : return $ value ; } }
Converter method to convert a BSON object to its legacy type

@param BSON\Type $value
@return mixed
Converter method to convert a BSON object to its legacy type