original_string: private function handleJsonError(int $code, $data): string
      {
          if ($code !== JSON_ERROR_UTF8) {
              $this->throwEncodeError($code, $data);
          }
  
          if (is_string($data)) {
              $this->detectAndCleanUtf8($data);
          } elseif (is_array($data)) {
              array_walk_recursive($data, [$this, 'detectAndCleanUtf8']);
          } else {
              $this->throwEncodeError($code, $data);
          }
  
          $json = $this->jsonEncode($data);
  
          if ($json === false) {
              $this->throwEncodeError(json_last_error(), $data);
          }
  
          return $json;
      }
code: private function handleJsonError(int $code, $data): string
      {
          if ($code !== JSON_ERROR_UTF8) {
              $this->throwEncodeError($code, $data);
          }
  
          if (is_string($data)) {
              $this->detectAndCleanUtf8($data);
          } elseif (is_array($data)) {
              array_walk_recursive($data, [$this, 'detectAndCleanUtf8']);
          } else {
              $this->throwEncodeError($code, $data);
          }
  
          $json = $this->jsonEncode($data);
  
          if ($json === false) {
              $this->throwEncodeError(json_last_error(), $data);
          }
  
          return $json;
      }
code_tokens: private function handleJsonError ( int $ code , $ data ) : string { if ( $ code !== JSON_ERROR_UTF8 ) { $ this -> throwEncodeError ( $ code , $ data ) ; } if ( is_string ( $ data ) ) { $ this -> detectAndCleanUtf8 ( $ data ) ; } elseif ( is_array ( $ data ) ) { array_walk_recursive ( $ data , [ $ this , 'detectAndCleanUtf8' ] ) ; } else { $ this -> throwEncodeError ( $ code , $ data ) ; } $ json = $ this -> jsonEncode ( $ data ) ; if ( $ json === false ) { $ this -> throwEncodeError ( json_last_error ( ) , $ data ) ; } return $ json ; }
docstring: Handle a json_encode failure.
  
  If the failure is due to invalid string encoding, try to clean the
  input and encode again. If the second encoding attempt fails, the
  initial error is not encoding related or the input can't be cleaned then
  raise a descriptive exception.
  
  @param  int               $code return code of json_last_error function
  @param  mixed             $data data that was meant to be encoded
  @throws \RuntimeException if failure can't be corrected
  @return string            JSON encoded data after error correction
docstring_tokens: Handle a json_encode failure .