protected function setMaxAge($maxage): void
    {
        $now = time();
        if (is_int($maxage)) {
            if ($maxage > $now) {
                $this->maxage = $maxage - $now;
                return;
            }
            if ($maxage >= 0) {
                $this->maxage = $maxage;
                return;
            }
            throw \AWonderPHP\FileWrapper\InvalidArgumentException::negativeMaxAge();
        }
        if ($maxage instanceof \DateInterval) {
            $dt = new \DateTime();
            $dt->add($maxage);
            $ts = $dt->getTimestamp();
            $seconds = $ts - $now;
            if ($seconds >= 0) {
                $this->maxage = $seconds;
                return;
            }
            throw \AWonderPHP\FileWrapper\InvalidArgumentException::negativeMaxAge();
        }
        if (! is_string($maxage)) {
            throw \AWonderPHP\FileWrapper\TypeErrorException::maxageWrongType($maxage);
        }
        if ($tstamp = strtotime($maxage, time())) {
            $seconds = $tstamp - $now;
            if ($seconds >= 0) {
                $this->maxage = $seconds;
                return;
            }
            throw \AWonderPHP\FileWrapper\InvalidArgumentException::negativeMaxAge();
        }
        throw \AWonderPHP\FileWrapper\InvalidArgumentException::invalidDateString();
    }