public function __construct() { $numargs = func_num_args(); $this->token = new TPTokenData(); if ($numargs == 1 && func_get_arg(0) instanceof TPTokenData) { $this->token = func_get_arg(0); return; } if ($numargs == 1 && func_get_arg(0) instanceof TPRID) { $rid = TPRID::parse(func_get_arg(0)); $this->token->addField(TPTokenData::RID, $rid->toString()); return; } if ($numargs == 2) { $rid = TPRID::parse(func_get_arg(0)); $expiration = func_get_arg(1); $this->token->addField(TPTokenData::RID, $rid->toString()); $this->token->addField(TPTokenData::EX, $expiration != null ? TPTokenData::convertToEpochSeconds($expiration) : 0); return; } if ($numargs == 3) { $rid = TPRID::parse(func_get_arg(0)); $expiration = func_get_arg(1); $eex = func_get_arg(2); $this->token->addField(TPTokenData::RID, $rid->toString()); $this->token->addField(TPTokenData::EX, $expiration != null ? TPTokenData::convertToEpochSeconds($expiration) : 0); $this->token->addField(TPTokenData::EARLY_EX, $eex != null ? TPTokenData::convertToEpochSeconds($eex) : 0); return; } }
public function isActive($timestampSecs) { $timestampSecs = TPTokenData::convertToEpochSeconds($timestampSecs); if ($this->getStartDateInSecs() != null && $this->getStartDateInSecs() > $timestampSecs) { return false; } if ($this->getEndDateInSecs() != null && $this->getEndDateInSecs() < $timestampSecs) { return false; } return true; }