set('idOwner', $data); $this->markNew(); $this->createToken(); } $this->log()->debug("Values after instantiation", $this->data); } protected function fields(array ...$superFields): array { return parent::fields([ 'id' => IntKey::class, 'idOwner' => IntKey::class, 'owner' => Owner::class, 'string' => Varchar::class, 'creationTime' => DateTime::class, ], ...$superFields); } /** * Returns a random generated token consisting of letters and numbers * * @param int $length The character length of the token * @return string The token */ public function createToken(int $length = 64): string { $this->string = bin2hex(random_bytes($length/2)); $this->creationTime = new \DateTimeImmutable(); return $this->string; } /** * Checks if the token is still valid * * @return true if creationTime not older than 14 days */ public function good(): bool { return ($this->creationTime->value()->diff(new \DateTimeImmutable())->days < 14); } } /* jEdit buffer local properties {{{ * :folding=explicit:collapseFolds=1: }}}*/