original_string: public static function cookies()
      {
          return function (callable $handler) {
              return function ($request, array $options) use ($handler) {
                  if (empty($options['cookies'])) {
                      return $handler($request, $options);
                  } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
                      throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
                  }
                  $cookieJar = $options['cookies'];
                  $request = $cookieJar->withCookieHeader($request);
                  return $handler($request, $options)
                      ->then(
                          function ($response) use ($cookieJar, $request) {
                              $cookieJar->extractCookies($request, $response);
                              return $response;
                          }
                  );
              };
          };
      }
code: public static function cookies()
      {
          return function (callable $handler) {
              return function ($request, array $options) use ($handler) {
                  if (empty($options['cookies'])) {
                      return $handler($request, $options);
                  } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
                      throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
                  }
                  $cookieJar = $options['cookies'];
                  $request = $cookieJar->withCookieHeader($request);
                  return $handler($request, $options)
                      ->then(
                          function ($response) use ($cookieJar, $request) {
                              $cookieJar->extractCookies($request, $response);
                              return $response;
                          }
                  );
              };
          };
      }
code_tokens: public static function cookies ( ) { return function ( callable $ handler ) { return function ( $ request , array $ options ) use ( $ handler ) { if ( empty ( $ options [ 'cookies' ] ) ) { return $ handler ( $ request , $ options ) ; } elseif ( ! ( $ options [ 'cookies' ] instanceof CookieJarInterface ) ) { throw new \ InvalidArgumentException ( 'cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface' ) ; } $ cookieJar = $ options [ 'cookies' ] ; $ request = $ cookieJar -> withCookieHeader ( $ request ) ; return $ handler ( $ request , $ options ) -> then ( function ( $ response ) use ( $ cookieJar , $ request ) { $ cookieJar -> extractCookies ( $ request , $ response ) ; return $ response ; } ) ; } ; } ; }
docstring: Middleware that adds cookies to requests.
  
  The options array must be set to a CookieJarInterface in order to use
  cookies. This is typically handled for you by a client.
  
  @return callable Returns a function that accepts the next handler.
docstring_tokens: Middleware that adds cookies to requests .