Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function __construct($collectionOrUrl, string $db = null, string $collection = null) |
||
26 | { |
||
27 | if ($collectionOrUrl instanceof \MongoDB\Collection) { |
||
28 | $this->collection = $collectionOrUrl; |
||
29 | return; |
||
30 | } |
||
31 | |||
32 | if (!is_string($collectionOrUrl)) { |
||
33 | throw new \InvalidArgumentException('$collectionOrUrl was not a string'); |
||
34 | } |
||
35 | |||
36 | $mongo = new \MongoDB\Client( |
||
37 | $collectionOrUrl, |
||
38 | [], |
||
39 | ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']] |
||
40 | ); |
||
41 | $mongoDb = $mongo->selectDatabase($db); |
||
42 | $this->collection = $mongoDb->selectCollection($collection); |
||
43 | } |
||
44 | } |
||
45 |