for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* (c) FSi sp. z o.o. <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace FSi\Bundle\AdminSecurityBundle\Security\Token;
use DateInterval;
use DateTime;
class Token implements TokenInterface
{
* @var string
protected $token;
* @var DateTime
protected $createdAt;
protected $expiresAt;
public function __construct(string $token, DateTime $createdAt, DateInterval $ttl)
$this->token = $token;
$this->createdAt = clone $createdAt;
$this->expiresAt = clone $this->createdAt;
$this->expiresAt->add($ttl);
}
public function getToken(): string
return $this->token;
public function getExpiresAt(): DateTime
return $this->expiresAt;
public function isNonExpired(): bool
return new DateTime() <= $this->expiresAt;