public static function isValidFormat($format, $throw = false)
    {
        if (in_array($format, static::getFormats(), true)) {
            return true;
        }

        if ($throw) {
            throw new InvalidArgumentException("Unknown format '$format'.");
        }

        return false;
    }