for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Acquia\Cloud\Database;
class DatabaseCredentials extends \ArrayObject
{
/**
* @return int
*/
public function id()
return $this['id'];
}
public function clusterId()
return $this['db_cluster_id'];
* @return string
public function role()
return $this['role'];
public function databaseName()
return $this['name'];
public function username()
return $this['user'];
public function password()
return $this['pass'];
public function port()
return $this['port'];
public function host()
return $this['host'];
* @return array
public function urls()
return $this['db_url_ha'];
public function activeUrl()
$host = $this->host();
$urls = $this->urls();
return $urls[$host];
* Returns the DSN for the active host.
*
* @throws \OutOfBoundsException
public function dsn()
// @see https://github.com/acquia/acquia-sdk-php/issues/27
if (!isset($this['name'])) {
throw new \OutOfBoundsException('Malformed response: expecting "name" property');
if (!isset($this['host'])) {
throw new \OutOfBoundsException('Malformed response: expecting "host" property');
if (!isset($this['port'])) {
throw new \OutOfBoundsException('Malformed response: expecting "port" property');
return 'mysql:dbname=' . $this['name'] . ';host=' . $this['host'] . ';port=' . $this['port'];
public function __toString()
return $this->dsn();