Skip to content

PHPLIB-89: String getters for Database and Collection classes #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public function __construct(Manager $manager, $namespace, WriteConcern $writeCon
list($this->dbname, $this->collname) = explode(".", $namespace, 2);
}

/**
* Return the collection namespace.
*
* @param string
*/
public function __toString()
{
return $this->ns;
}

/**
* Runs an aggregation framework pipeline
*
Expand Down Expand Up @@ -629,7 +639,7 @@ public function getBulkOptions()
}

/**
* Returns the CollectionName this object operates on
* Return the collection name.
*
* @return string
*/
Expand Down Expand Up @@ -677,7 +687,7 @@ public function getCountOptions()
}

/**
* Returns the DatabaseName this object operates on
* Return the database name.
*
* @return string
*/
Expand Down Expand Up @@ -931,6 +941,17 @@ public function getFindOptions()
);
}

/**
* Return the collection namespace.
*
* @see http://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace
* @return string
*/
public function getNamespace()
{
return $this->ns;
}

/**
* Retrieves all Write options with their default values.
*
Expand Down
20 changes: 20 additions & 0 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public function __construct(Manager $manager, $databaseName, WriteConcern $write
$this->readPreference = $readPreference;
}

/**
* Return the database name.
*
* @param string
*/
public function __toString()
{
return $this->databaseName;
}

/**
* Create a new collection explicitly.
*
Expand Down Expand Up @@ -89,6 +99,16 @@ public function dropCollection($collectionName)
return $this->manager->executeCommand($this->databaseName, $command, $readPreference);
}

/**
* Returns the database name.
*
* @return string
*/
public function getDatabaseName()
{
return $this->databaseName;
}

/**
* Returns information for all collections in this database.
*
Expand Down