The MongoDB\Builder\BuilderEncoder doesn't allow dependency injection of sub-encoders. https://github.com/mongodb/mongo-php-library/blob/fda4a4c70d62cbe4e379e17b4670310d25e967af/src/Builder/BuilderEncoder.php#L98
In order to accept more advanced use-cases (like using a service in the encoder to map field names), allow injecting instances of Encoder into the constructor.
Issue similar to https://github.com/doctrine/dbal/pull/6705/