original_string: public function handleResponse($response)
      {
          // recursion for batch
          if (is_array($response)) {
              $response_arr = array();
              foreach ($response as $res) {
                  $response_arr[$res->id] = $this->handleResponse($res);
              }
              return $response_arr;
          }
  
          // return error response
          if (property_exists($response, 'error')) {
              return new Response(null, $response->id, $response->error->code, $response->error->message);
          }
  
          // return successful response
          return new Response($response->result, $response->id);
      }
code: public function handleResponse($response)
      {
          // recursion for batch
          if (is_array($response)) {
              $response_arr = array();
              foreach ($response as $res) {
                  $response_arr[$res->id] = $this->handleResponse($res);
              }
              return $response_arr;
          }
  
          // return error response
          if (property_exists($response, 'error')) {
              return new Response(null, $response->id, $response->error->code, $response->error->message);
          }
  
          // return successful response
          return new Response($response->result, $response->id);
      }
code_tokens: public function handleResponse ( $ response ) { // recursion for batch if ( is_array ( $ response ) ) { $ response_arr = array ( ) ; foreach ( $ response as $ res ) { $ response_arr [ $ res -> id ] = $ this -> handleResponse ( $ res ) ; } return $ response_arr ; } // return error response if ( property_exists ( $ response , 'error' ) ) { return new Response ( null , $ response -> id , $ response -> error -> code , $ response -> error -> message ) ; } // return successful response return new Response ( $ response -> result , $ response -> id ) ; }
docstring: handle the response and return a result or an error
docstring_tokens: handle the response and return a result or an error