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

        if ($ttl instanceof DateInterval) {
            $reference = new DateTimeImmutable();
            $endTime = $reference->add($ttl);

            $ttl = $endTime->getTimestamp() - $reference->getTimestamp();
        }

        if (!is_int($ttl)) {
            $type = (is_object($ttl) ? get_class($ttl) . ' ' : '') . gettype($ttl);
            throw new InvalidArgumentException("ttl should be of type int or DateInterval, not $type");
        }

        return isset($this->ttl) ? min($ttl, $this->ttl) : $ttl;
    }
protected function ttlToSeconds($ttl): ?int
    {
        if (!isset($ttl)) {
            return $this->ttl;
        }

        if ($ttl instanceof DateInterval) {
            $reference = new DateTimeImmutable();
            $endTime = $reference->add($ttl);

            $ttl = $endTime->getTimestamp() - $reference->getTimestamp();
        }

        if (!is_int($ttl)) {
            $type = (is_object($ttl) ? get_class($ttl) . ' ' : '') . gettype($ttl);
            throw new InvalidArgumentException("ttl should be of type int or DateInterval, not $type");
        }

        return isset($this->ttl) ? min($ttl, $this->ttl) : $ttl;
    }
protected function ttlToSeconds ( $ ttl ) : ? int { if ( ! isset ( $ ttl ) ) { return $ this -> ttl ; } if ( $ ttl instanceof DateInterval ) { $ reference = new DateTimeImmutable ( ) ; $ endTime = $ reference -> add ( $ ttl ) ; $ ttl = $ endTime -> getTimestamp ( ) - $ reference -> getTimestamp ( ) ; } if ( ! is_int ( $ ttl ) ) { $ type = ( is_object ( $ ttl ) ? get_class ( $ ttl ) . ' ' : '' ) . gettype ( $ ttl ) ; throw new InvalidArgumentException ( "ttl should be of type int or DateInterval, not $type" ) ; } return isset ( $ this -> ttl ) ? min ( $ ttl , $ this -> ttl ) : $ ttl ; }
Convert TTL to seconds from now

@param null|int|DateInterval $ttl
@return int|null
@throws InvalidArgumentException
Convert TTL to seconds from now