src/AbstractCache.php
protected function ttlToTimestamp($ttl): ?int
    {
        if (!isset($ttl)) {
            return isset($this->ttl) ? time() + $this->ttl : null;
        }

        if (is_int($ttl)) {
            return time() + (isset($this->ttl) ? min($ttl, $this->ttl) : $ttl);
        }

        if ($ttl instanceof DateInterval) {
            $timestamp = (new DateTimeImmutable())->add($ttl)->getTimestamp();

            return isset($this->ttl) ? min($timestamp, time() + $this->ttl) : $timestamp;
        }

        $type = (is_object($ttl) ? get_class($ttl) . ' ' : '') . gettype($ttl);
        throw new InvalidArgumentException("ttl should be of type int or DateInterval, not $type");
    }
protected function ttlToTimestamp($ttl): ?int
    {
        if (!isset($ttl)) {
            return isset($this->ttl) ? time() + $this->ttl : null;
        }

        if (is_int($ttl)) {
            return time() + (isset($this->ttl) ? min($ttl, $this->ttl) : $ttl);
        }

        if ($ttl instanceof DateInterval) {
            $timestamp = (new DateTimeImmutable())->add($ttl)->getTimestamp();

            return isset($this->ttl) ? min($timestamp, time() + $this->ttl) : $timestamp;
        }

        $type = (is_object($ttl) ? get_class($ttl) . ' ' : '') . gettype($ttl);
        throw new InvalidArgumentException("ttl should be of type int or DateInterval, not $type");
    }
protected function ttlToTimestamp ( $ ttl ) : ? int { if ( ! isset ( $ ttl ) ) { return isset ( $ this -> ttl ) ? time ( ) + $ this -> ttl : null ; } if ( is_int ( $ ttl ) ) { return time ( ) + ( isset ( $ this -> ttl ) ? min ( $ ttl , $ this -> ttl ) : $ ttl ) ; } if ( $ ttl instanceof DateInterval ) { $ timestamp = ( new DateTimeImmutable ( ) ) -> add ( $ ttl ) -> getTimestamp ( ) ; return isset ( $ this -> ttl ) ? min ( $ timestamp , time ( ) + $ this -> ttl ) : $ timestamp ; } $ type = ( is_object ( $ ttl ) ? get_class ( $ ttl ) . ' ' : '' ) . gettype ( $ ttl ) ; throw new InvalidArgumentException ( "ttl should be of type int or DateInterval, not $type" ) ; }
Convert TTL to epoch timestamp

@param null|int|DateInterval $ttl
@return int|null
@throws InvalidArgumentException
Convert TTL to epoch timestamp