File: //usr/local/mailchannels/models/Subscription.php
<?php
namespace MailChannels;
class Subscription implements \JsonSerializable {
private $handle;
private $active;
private $plan;
private $limits;
private $activeAccountsCount;
private $protectedDomainsLimit;
public function __construct($handle, $active, Plan $plan = null, array $limits = null, $activeAccountsCount = 0) {
$this->handle = $handle;
$this->active = $active;
$this->plan = $plan;
$this->limits = $limits;
$this->activeAccountsCount = $activeAccountsCount;
$this->protectedDomainsLimit = 0;
if ($limits !== null) {
foreach ($limits as $limit) {
if (!$limit instanceof Limit) {
throw new \InvalidArgumentException("all elements of 'limits' array must be instances of 'Limit'");
}
if ($limit->getFeatureHandle() === Limit::PROTECTED_DOMAINS_FEATURE_HANDLE) {
$this->protectedDomainsLimit = intval($limit->getValue());
}
}
}
}
public function getHandle() {
return $this->handle;
}
public function getActive() {
return $this->active;
}
public function getPlan() {
return $this->plan;
}
public function getLimits() {
return $this->limits;
}
public function getActiveAccountsCount() {
return $this->activeAccountsCount;
}
public function getProtectedDomainsLimit() {
return $this->protectedDomainsLimit;
}
function jsonSerialize() {
return [
'handle'=>$this->handle,
'active'=>$this->active,
'plan'=>$this->plan,
'limits'=>$this->limits
];
}
}