public function __construct(array $data, Subscription $subscription = null)
{
// process data array
$this->startDate = new \DateTime();
foreach ($data as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
// fill paidDays with days value
if (!$this->paidDays) {
$this->paidDays = $this->days;
}
if (!$subscription) {
$this->subscription = new Subscription();
} else {
$this->subscription = $subscription;
}
return $this;
}