protected function parseMaxAge(ServerRequestInterface $request) : int
    {
        $item = $this->settings['maxAge'];
        // we allow callables to be set (along with strings) so we can vary things upon requests.
        if (true === is_callable($item)) {
            // all callbacks are made with the request as the second parameter.
            $item = call_user_func($item, $request);
        }

        // maxAge needs to be an int - if it isn't, throw an exception.
        if (false === is_int($item)) {
            throw new \InvalidArgumentException('maxAge should be an int value');
        }

        // if it is less than zero, reject it as "faulty"
        if ($item < 0) {
            throw new \InvalidArgumentException('maxAge should be 0 or more');
        }

        // return our integer maximum age to cache.
        return $item;
    }