original_string: protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg)
      {
          $itemArray  = $msg->getAllArticleItems();
          $itemStr    = '';
          foreach ($itemArray as $item) {
              $itemStr .= $this->sendNewsItemToJsonString($item) . ',';
          }
  
          $itemStr    = substr($itemStr, 0, -1);
  
          $formatStr = '{
                          "touser":"%s",
                          "msgtype":"%s",
                          "news":{
                              "articles": [
                               %s
                               ]
                          }
                      }';
  
          $result = sprintf($formatStr,   $msg->getToUserName(),
                                          $msg->getMsgType(),
                                          $itemStr
                              );
  
          return $result;
      }
code: protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg)
      {
          $itemArray  = $msg->getAllArticleItems();
          $itemStr    = '';
          foreach ($itemArray as $item) {
              $itemStr .= $this->sendNewsItemToJsonString($item) . ',';
          }
  
          $itemStr    = substr($itemStr, 0, -1);
  
          $formatStr = '{
                          "touser":"%s",
                          "msgtype":"%s",
                          "news":{
                              "articles": [
                               %s
                               ]
                          }
                      }';
  
          $result = sprintf($formatStr,   $msg->getToUserName(),
                                          $msg->getMsgType(),
                                          $itemStr
                              );
  
          return $result;
      }
code_tokens: protected function sendNewsMsgToJsonString ( WxSendNewsMsg $ msg ) { $ itemArray = $ msg -> getAllArticleItems ( ) ; $ itemStr = '' ; foreach ( $ itemArray as $ item ) { $ itemStr .= $ this -> sendNewsItemToJsonString ( $ item ) . ',' ; } $ itemStr = substr ( $ itemStr , 0 , - 1 ) ; $ formatStr = '{
                          "touser":"%s",
                          "msgtype":"%s",
                          "news":{
                              "articles": [
                               %s
                               ]
                          }
                      }' ; $ result = sprintf ( $ formatStr , $ msg -> getToUserName ( ) , $ msg -> getMsgType ( ) , $ itemStr ) ; return $ result ; }
docstring: formatter WxSendNewsMsg to Json string
  @param WxSendNewsMsg $msg
  @return string
docstring_tokens: formatter WxSendNewsMsg to Json string