public function unregisterMiddleware(IMiddleware $middleware): IOAuthClient
    {
        $middlewareClass = get_class($middleware);
        foreach ($middleware::statusCode() as $statusCode) {
            if (!isset($this->postRequestMiddlewares[$statusCode])) {
                continue;
            }
            $result = array_filter(
                $this->postRequestMiddlewares[$statusCode],
                function (IMiddleware $currMiddleware) use ($middlewareClass) {
                    return get_class($currMiddleware) != $middlewareClass;
                }
            );

            if (empty($result)) {
                unset($this->postRequestMiddlewares[$statusCode]);
            } else {
                $this->postRequestMiddlewares[$statusCode] = $result;
            }
        }

        return $this;
    }