Skip to content

Commit ae88c82

Browse files
committed
Refactor getCollection and hasCollection
1 parent 2dcfa5b commit ae88c82

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Jenssegers/Mongodb/Schema/Builder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public function hasCollection($name)
4040
{
4141
$db = $this->connection->getMongoDB();
4242

43-
$collections = $db->listCollections([
43+
$collections = iterator_to_array($db->listCollections([
4444
'filter' => [
4545
'name' => $name,
4646
],
47-
]);
47+
]), false);
4848

49-
return $collections->count() ? true : false;
49+
return count($collections) ? true : false;
5050
}
5151

5252
/**
@@ -143,13 +143,13 @@ public function getCollection($name)
143143
{
144144
$db = $this->connection->getMongoDB();
145145

146-
$collections = $db->listCollections([
146+
$collections = iterator_to_array($db->listCollections([
147147
'filter' => [
148148
'name' => $name,
149149
],
150-
]);
150+
]), false);
151151

152-
return $collections->count() ? (($collections = iterator_to_array($collections) ) ? current($collections) : false) : false;
152+
return count($collections) ? current($collections) : false;
153153
}
154154

155155
/**

0 commit comments

Comments
 (0)