@@ -49,6 +49,11 @@ class ListCollections implements Executable
4949 *
5050 * Supported options:
5151 *
52+ * * authorizedCollections (boolean): Determines which collections are
53+ * returned based on the user privileges.
54+ *
55+ * For servers < 4.0, this option is ignored.
56+ *
5257 * * filter (document): Query by which to filter collections.
5358 *
5459 * * maxTimeMS (integer): The maximum amount of time to allow the query to
@@ -68,6 +73,10 @@ class ListCollections implements Executable
6873 */
6974 public function __construct ($ databaseName , array $ options = [])
7075 {
76+ if (isset ($ options ['authorizedCollections ' ]) && ! is_bool ($ options ['authorizedCollections ' ])) {
77+ throw InvalidArgumentException::invalidType ('"authorizedCollections" option ' , $ options ['authorizedCollections ' ], 'boolean ' );
78+ }
79+
7180 if (isset ($ options ['filter ' ]) && ! is_array ($ options ['filter ' ]) && ! is_object ($ options ['filter ' ])) {
7281 throw InvalidArgumentException::invalidType ('"filter" option ' , $ options ['filter ' ], 'array or object ' );
7382 }
@@ -104,12 +113,10 @@ public function execute(Server $server)
104113 $ cmd ['filter ' ] = (object ) $ this ->options ['filter ' ];
105114 }
106115
107- if (isset ($ this ->options ['maxTimeMS ' ])) {
108- $ cmd ['maxTimeMS ' ] = $ this ->options ['maxTimeMS ' ];
109- }
110-
111- if (isset ($ this ->options ['nameOnly ' ])) {
112- $ cmd ['nameOnly ' ] = $ this ->options ['nameOnly ' ];
116+ foreach (['authorizedCollections ' , 'maxTimeMS ' , 'nameOnly ' ] as $ option ) {
117+ if (isset ($ this ->options [$ option ])) {
118+ $ cmd [$ option ] = $ this ->options [$ option ];
119+ }
113120 }
114121
115122 $ cursor = $ server ->executeReadCommand ($ this ->databaseName , new Command ($ cmd ), $ this ->createOptions ());
0 commit comments