/**
* Constructor
*
* @param ArrayCollection $collection Collection of the projects
* @param string $ccId Identifier of the cost centre to check
* @param Scalr_Account_User $user optional The user
* @param Scalr_Environment $environment optional An envrironment
* @throws InvalidArgumentException
*/
public function __construct(ArrayCollection $collection, $ccId, Scalr_Account_User $user = null, Scalr_Environment $environment = null)
{
parent::__construct($collection->getIterator());
if ($user !== null && !$user instanceof Scalr_Account_User) {
throw new InvalidArgumentException("User argument must be instance of the Scalr_Account_User class.");
}
$this->user = $user;
if ($environment !== null && !$environment instanceof Scalr_Environment) {
throw new InvalidArgumentException("Environment argument must be instance of the Scalr_Environment class.");
}
$this->environment = $environment;
$this->ccId = $ccId;
$this->default = $this->user === null && $this->environment === null;
}