Skip to content

Commit

Permalink
PHPLIB-74: Use array and document classes in default type map
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Jan 5, 2016
1 parent 8a10a28 commit a7eb183
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class Client
*/
public function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [])
{
$driverOptions += [
'typeMap' => [
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
],
];

if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) {
throw new InvalidArgumentTypeException('"typeMap" driver option', $driverOptions['typeMap'], 'array');
}
Expand Down

0 comments on commit a7eb183

Please sign in to comment.