1 | <?php |
||
9 | class MongoDbDriver extends AbstractDriver |
||
10 | { |
||
11 | /** |
||
12 | * @var MongoDBClient |
||
13 | */ |
||
14 | private $connection; |
||
15 | |||
16 | /** |
||
17 | * Driver constructor. |
||
18 | * |
||
19 | * @param MongoDBClient $connection |
||
20 | * @param string $database |
||
21 | */ |
||
22 | 5 | public function __construct(MongoDBClient $connection, $database) |
|
27 | |||
28 | /** |
||
29 | * @return \MongoDB\Database |
||
30 | */ |
||
31 | public function getDatabase() |
||
35 | |||
36 | /** |
||
37 | * @param int|string $id |
||
38 | * |
||
39 | * @return ObjectID |
||
40 | */ |
||
41 | 2 | public function createObjectId($id) |
|
45 | |||
46 | /** |
||
47 | * @return MongoDBClient |
||
48 | */ |
||
49 | public function getConnection() |
||
53 | |||
54 | /** |
||
55 | * @param \Iterator $cursor |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public function fetch(\Iterator $cursor) |
||
69 | |||
70 | /** |
||
71 | * @param array $collection |
||
72 | * @param array $query |
||
73 | * |
||
74 | * @return \Iterator |
||
75 | */ |
||
76 | public function find($collection, array $query = []) |
||
84 | |||
85 | /** |
||
86 | * @param Collection $collection |
||
87 | * @param $document |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public function insert($collection, $document) |
||
96 | |||
97 | public function update($collection, $criteria, $document) |
||
101 | |||
102 | /** |
||
103 | * @param string $collection |
||
104 | * @param array $criteria |
||
105 | */ |
||
106 | public function remove($collection, $criteria) |
||
110 | } |
||
111 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: