1 | <?php |
||
14 | class MongoDbDriver implements NoSqlDriverInterface |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var MongoDB |
||
19 | */ |
||
20 | protected $dataset = null; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @var MongoClient; |
||
25 | */ |
||
26 | protected $mongoClient = null; |
||
27 | |||
28 | /** |
||
29 | * Enter description here... |
||
30 | * |
||
31 | * @var ConnectionManagement |
||
32 | */ |
||
33 | protected $connectionManagement; |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * @var MongoCollection MongoDB collection |
||
38 | */ |
||
39 | protected $collection; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $collectionName; |
||
46 | |||
47 | /** |
||
48 | * Creates a new MongoDB connection. This class is managed from NoSqlDataset |
||
49 | * |
||
50 | * @param ConnectionManagement $connMngt |
||
51 | * @param string $collection |
||
52 | */ |
||
53 | public function __construct($connMngt, $collection) |
||
75 | |||
76 | /** |
||
77 | * Closes and destruct the MongoDB connection |
||
78 | */ |
||
79 | public function __destruct() |
||
84 | |||
85 | /** |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getCollection() |
||
93 | |||
94 | /** |
||
95 | * Gets the instance of MongoDB; You do not need uses this directly. |
||
96 | * If you have to, probably something is missing in this class |
||
97 | * @return \MongoDB |
||
98 | */ |
||
99 | public function getDbConnection() |
||
103 | |||
104 | /** |
||
105 | * Return a IteratorInterface |
||
106 | * |
||
107 | * @param array $filter |
||
108 | * @param array $fields |
||
109 | * @return ArrayDatasetIterator |
||
110 | */ |
||
111 | public function getIterator($filter = null, $fields = null) |
||
124 | |||
125 | /** |
||
126 | * Insert a document in the MongoDB |
||
127 | * @param mixed $document |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function insert($document) |
||
140 | |||
141 | /** |
||
142 | * Defines the new Collection |
||
143 | * @param string $collection |
||
144 | */ |
||
145 | public function setCollection($collection) |
||
150 | |||
151 | /** |
||
152 | * Update a document based on your criteria |
||
153 | * |
||
154 | * Options for MongoDB is an array of: |
||
155 | * |
||
156 | * sort array Determines which document the operation will modify if the |
||
157 | * query selects multiple documents. findAndModify will modify |
||
158 | * the first document in the sort order specified by this argument. |
||
159 | * remove boolean Optional if update field exists. When TRUE, removes the |
||
160 | * selected document. The default is FALSE. |
||
161 | * update array Optional if remove field exists. Performs an update of the |
||
162 | * selected document. |
||
163 | * new boolean Optional. When TRUE, returns the modified document rather than the original. |
||
164 | * The findAndModify method ignores the new option for remove operations. |
||
165 | * The default is FALSE. |
||
166 | * upsert boolean ptional. Used in conjunction with the update field. When TRUE, |
||
167 | * the findAndModify command creates a new document if the query |
||
168 | * returns no documents. The default is false. In MongoDB 2.2, the findAndModify |
||
169 | * command returns NULL when upsert is TRUE. |
||
170 | * |
||
171 | * @param mixed $document |
||
172 | * @param array $filter |
||
173 | * @param array $options See: |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function update($document, $filter = null, $options = null) |
||
202 | /* |
||
203 | public function getAttribute($name) |
||
204 | { |
||
205 | $this->_db->getAttribute($name); |
||
206 | } |
||
207 | |||
208 | public function setAttribute($name, $value) |
||
209 | { |
||
210 | $this->_db->setAttribute ( $name, $value ); |
||
211 | } |
||
212 | */ |
||
213 | } |
||
214 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.