Skip to content

Commit 6784ad6

Browse files
committed
Revise docs and exception output
1 parent 7656c7b commit 6784ad6

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

docs/includes/apiargs-MongoDBDatabase-method-createEncryptedCollection-param.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ name: $masterKey
3030
type: array|null
3131
description: |
3232
KMS-specific key options that will be used to encrypt new data keys. This
33-
corresponds to the ``$masterKey`` parameter for
33+
corresponds to the ``masterKey`` option for
3434
:php:`MongoDB\\Driver\\ClientEncryption::createDataKey() <mongodb-driver-clientencryption.createdatakey>`.
3535
3636
If ``$kmsProvider`` is "local", this should be ``null``.

docs/reference/exception-classes.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ MongoDB\\Exception\\CreateEncryptedCollectionException
3737

3838
Thrown by :phpmethod:`MongoDB\\Database::createEncryptedCollection()` if any
3939
error is encountered while creating data keys or invoking
40-
``createCollection()``. The original exception and modified
41-
``encryptedFields`` option can be accessed via ``getPrevious()`` and
42-
``getEncryptedFields()``, respectively.
40+
:phpmethod:`createCollection() <MongoDB\\Database::createCollection()>`. The
41+
original exception and modified ``encryptedFields`` option can be accessed
42+
via the ``getPrevious()`` and ``getEncryptedFields()`` methods, respectively.
4343

4444
This class extends the library's :phpclass:`RuntimeException
4545
<MongoDB\\Exception\\RuntimeException>` class.

docs/reference/method/MongoDBDatabase-createEncryptedCollection.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Definition
2121

2222
.. code-block:: php
2323

24-
function createEncryptedCollection(string $collectionName, ClientEncryption $clientEncryption, string $kmsProvider, ?array $masterKey, array $options): array
24+
function createEncryptedCollection(string $collectionName, MongoDB\Driver\ClientEncryption $clientEncryption, string $kmsProvider, ?array $masterKey, array $options): array
2525

2626
This method wraps :phpmethod:`MongoDB\\Database::createCollection()` and will
2727
automatically create data keys for any encrypted fields where the ``keyId``

src/Database.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,29 +305,28 @@ public function createCollection(string $collectionName, array $options = [])
305305
}
306306

307307
/**
308-
* Create a new encrypted collection.
308+
* Create a new encrypted collection explicitly.
309309
*
310310
* This function will automatically create data keys for any encrypted
311311
* fields where the "keyId" option is null. This function will return a copy
312312
* of the modified "encryptedFields" option in addition to the result from
313-
* createCollection().
314-
*
315-
* This function requires that the "encryptedFields" option be specified.
313+
* createCollection(). The "encryptedFields" option is required.
316314
*
317315
* If any error is encountered while creating data keys or invoking
318316
* createCollection(), a CreateEncryptedCollectionException will be thrown.
319317
* The original exception and modified "encryptedFields" option can be
320-
* accessed via getPrevious() and getEncryptedFields(), respectively.
318+
* accessed via the getPrevious() and getEncryptedFields() methods,
319+
* respectively.
321320
*
322321
* @see CreateCollection::__construct() for supported options
323322
* @return array A tuple consisting of the createCollection() result and modified "encryptedFields" option
324323
* @throws InvalidArgumentException for parameter/option parsing errors
325-
* @throws CreateEncryptedCollectionException for errors generating data keys or invoking createCollection
324+
* @throws CreateEncryptedCollectionException for any errors creating data keys or invoking createCollection()
326325
*/
327326
public function createEncryptedCollection(string $collectionName, ClientEncryption $clientEncryption, string $kmsProvider, ?array $masterKey, array $options): array
328327
{
329328
if (! isset($options['encryptedFields']) || ! is_array($options['encryptedFields']) && ! is_object($options['encryptedFields'])) {
330-
throw InvalidArgumentException::invalidType('"encryptedFields" option', $options['encryptedFields'] ?? null, 'array or object');
329+
throw InvalidArgumentException::invalidType('"encryptedFields" option', $options['encryptedFields'] ?? null, ['array', 'object']);
331330
}
332331

333332
$encryptedFields = (array) recursive_copy($options['encryptedFields']);

0 commit comments

Comments
 (0)