1 | <?php |
||
14 | class MongoDBDriver implements NoSQLDriverInterface |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var MongoDB |
||
19 | */ |
||
20 | protected $_db = null; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @var MongoClient; |
||
25 | */ |
||
26 | protected $_client = 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. If you have to, probably something is missing in this class |
||
96 | * @return \MongoDB |
||
97 | */ |
||
98 | public function getDbConnection() |
||
102 | |||
103 | /** |
||
104 | * Return a IteratorInterface |
||
105 | * |
||
106 | * @param array $filter |
||
107 | * @param array $fields |
||
108 | * @return ArrayDatasetIterator |
||
109 | */ |
||
110 | public function getIterator($filter = null, $fields = null) |
||
123 | |||
124 | /** |
||
125 | * Insert a document in the MongoDB |
||
126 | * @param mixed $document |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function insert($document) |
||
139 | |||
140 | /** |
||
141 | * Defines the new Collection |
||
142 | * @param string $collection |
||
143 | */ |
||
144 | public function setCollection($collection) |
||
149 | |||
150 | /** |
||
151 | * Update a document based on your criteria |
||
152 | * |
||
153 | * Options for MongoDB is an array of: |
||
154 | * |
||
155 | * sort array Determines which document the operation will modify if the |
||
156 | * query selects multiple documents. findAndModify will modify |
||
157 | * the first document in the sort order specified by this argument. |
||
158 | * remove boolean Optional if update field exists. When TRUE, removes the |
||
159 | * selected document. The default is FALSE. |
||
160 | * update array Optional if remove field exists. Performs an update of the |
||
161 | * selected document. |
||
162 | * new boolean Optional. When TRUE, returns the modified document rather than the original. |
||
163 | * The findAndModify method ignores the new option for remove operations. |
||
164 | * The default is FALSE. |
||
165 | * upsert boolean Optional. Used in conjunction with the update field. When TRUE, |
||
166 | * the findAndModify command creates a new document if the query |
||
167 | * returns no documents. The default is false. In MongoDB 2.2, the findAndModify |
||
168 | * command returns NULL when upsert is TRUE. |
||
169 | * |
||
170 | * @param mixed $document |
||
171 | * @param array $filter |
||
172 | * @param array $options See: |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function update($document, $filter = null, $options = null) |
||
201 | /* |
||
202 | public function getAttribute($name) |
||
203 | { |
||
204 | $this->_db->getAttribute($name); |
||
205 | } |
||
206 | |||
207 | public function setAttribute($name, $value) |
||
208 | { |
||
209 | $this->_db->setAttribute ( $name, $value ); |
||
210 | } |
||
211 | */ |
||
212 | } |
||
213 |
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.