Commit 14667e36 authored by Jeremy Mikola's avatar Jeremy Mikola

Replace magic string with a private constant and comments

parent 53c481c8
......@@ -17,6 +17,7 @@ use MongoDB\Exception\RuntimeException;
*/
class DropCollection implements Executable
{
private static $errorMessageNamespaceNotFound = 'ns not found';
private $databaseName;
private $collectionName;
......@@ -44,7 +45,11 @@ class DropCollection implements Executable
try {
$cursor = $server->executeCommand($this->databaseName, new Command(array('drop' => $this->collectionName)));
} catch (DriverRuntimeException $e) {
if ($e->getMessage() === 'ns not found') {
/* The server may return an error if the collection does not exist.
* Check for an error message (unfortunately, there isn't a code)
* and NOP instead of throwing.
*/
if ($e->getMessage() === self::$errorMessageNamespaceNotFound) {
return (object) ['ok' => 0, 'errmsg' => 'ns not found'];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment