for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the XabbuhPandaClient package.
*
* (c) Christian Flothmann <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Xabbuh\PandaClient\Api;
/**
* Manager of all accounts which can be used in the application.
* @author Christian Flothmann <[email protected]>
class AccountManager implements AccountManagerInterface
{
* The default account's configuration key
* @var string
private $defaultAccountKey;
* The accounts being managed
* @var Account[]
private $accounts = array();
* {@inheritDoc}
public function registerAccount($key, Account $account)
$this->accounts[$key] = $account;
}
public function hasAccount($key)
return isset($this->accounts[$key]);
public function getAccount($key = null)
if (null === $key) {
$key = $this->defaultAccountKey;
if (!$this->hasAccount($key)) {
throw new \InvalidArgumentException('No account for key '.$key.' configured.');
return $this->accounts[$key];
public function setDefaultAccount($key)
$this->defaultAccountKey = $key;
public function getDefaultAccount()
return $this->getAccount($this->defaultAccountKey);