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