formatter WxSendMusicMsg to Json string
@param WxSendMusicMsg $msg
@return string
975614
protected function sendMusicMsgToJsonString(WxSendMusicMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "music":
                        {
                          "title":"%s",
                          "description":"%s",
                          "musicurl":"%s",
                          "hqmusicurl":"%s",
                          "thumb_media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getTitle(),
                                        $msg->getDescription(),
                                        $msg->getMusicUrl(),
                                        $msg->getHQMusicUrl(),
                                        $msg->getThumbMediaId()
                            );

        return $result;
    }
829134
public static function success($msg)
    {
        $msg = 'Success: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;

        return $out;
    }
198579
public function encodeJson($mMsg = null)
    {
        if (is_string($mMsg)) {
            if (!$this->isUtfString($mMsg)) {
                $mMsg = utf8_encode($mMsg);
            }
        } else {
            // Typecast for Objects
            if (is_object($mMsg)) {
                $mMsg = ( array ) $mMsg;
            }

            $mMsg = $this->_encodeUtf8Array($mMsg);
        }

        return json_encode($mMsg);
    }
1095749
public static function t($msg, $args = array())
    {
        assert('is_string($msg)');
        if (extension_loaded('gettext')) {
            bindtextdomain("phptoolkit", dirname(dirname(__DIR__)).'/locale');
            textdomain('phptoolkit');

            $translatedMsg = gettext($msg);
        } else {
            $translatedMsg = $msg;
        }
        if (!empty($args)) {
            $params = array_merge(array($translatedMsg), $args);
            $translatedMsg = call_user_func_array('sprintf', $params);
        }
        return $translatedMsg;
    }
1292809
protected function sendImageMsgToJsonString(WxSendImageMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "image":
                        {
                          "media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getMediaId()
                        );


        return $result;
    }
1212515
static public String getString(String msg, Object[] args)
	{
		String format = msg;

		if (bundle != null)
		{
			try
			{
				format = bundle.getString(msg);
			}
			catch (MissingResourceException e)
			{
			}
		}

		return format(format, args);
	}
868604
static public String getString(String msg)
	{
		if (bundle == null)
			return msg;
		try
		{
			return bundle.getString(msg);
		}
		catch (MissingResourceException e)
		{
			return "Missing message: " + msg; //$NON-NLS-1$
		}
	}
492846
public function formatMessageForBroadcast (TypeInterface $type)
    {
        $json = ['msgtype' => $type->getType()];

        $method = 'format' . ucfirst($type->getType()) . 'ForBroadcast';
        if (method_exists($this, $method)) {
            $json[$type->getType()] = $this->$method($type);
        } elseif ($type instanceof Uploaded) {
            $json[$type->getType()] = ['media_id' => $type->getMediaID()];
        }

        return $json;
    }
984981
public static function responseJson($mdata = array(), $status = null, $msg = '', array $headers = array(), $options = 0)
    {
        $response = self::response($mdata, $status, $msg);
        return Response::json($response, $response['status'], $headers, $options);
    }
982385
public static function decode($msg)
    {
        try {
            $data = json_decode($msg, true);

            return $data;
        } catch (\Exception $e) {
            throw new \InvalidArgumentException('Invalid json format');
        }
    }
274087
private function formatMessage($field, $msg, $params)
    {
        if (isset($this->attributes[$field])) {
            $msg = str_replace('{value}', $this->attributes[$field], $msg);
        }
        if (isset($this->_labels[$field])) {
            $msg = str_replace('{field}', $this->_labels[$field], $msg);
            if (is_array($params)) {
                $i = 1;
                foreach ($params as $k => $v) {
                    $tag = '{field' . $i . '}';
                    $label = isset($params[$k]) && (is_numeric($params[$k]) || is_string($params[$k])) && isset($this->_labels[$params[$k]]) ? $this->_labels[$params[$k]] : $tag;
                    $msg = str_replace($tag, $label, $msg);
                    $i++;
                }
            }
        } else {
            $msg = str_replace('{field}', $field, $msg);
        }
        return $msg;
    }
957943
protected function send($msg)
    {
        $msg .= PHP_EOL;

        return $this->socket->write($msg, strlen($msg));
    }
1217550
protected function createReceiveVideoMsg(array $data)
    {
        $result = new WxReceiveVideoMsg();
        $this->initReceiveMsg($result, $data);
        $result->setMediaId(isset($data['MediaId']) ? trim($data['MediaId']) : '');
        $result->setThumbMediaId(isset($data['ThumbMediaId']) ? trim($data['ThumbMediaId']) : '');
        return $result;
    }
947105
public static function success($msg)
        {
            // $msg    = 'Success: ' . $msg;
            $space  = strlen($msg) + 4;

            $out    = self::colorize(
                str_pad(' ', $space), Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            $out .= self::colorize(
                '  ' . $msg . '  ', Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            $out .= self::colorize(
                str_pad(' ', $space), Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            return $out;
        }
318675
public function message($config) : string
  {
    $config = $this->cleanString($config);
    return json_encode(config($config));
  }
1036167
public function pack($msg)
    {
        if (!$msg instanceof Message) {
            trigger_error("Given parameter is not a message instance.",
                          E_USER_ERROR);
            return;
        }

        // Set value using serialzed message.
        $this->value = $msg->serializeToString();

        // Set type url.
        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
        $desc = $pool->getDescriptorByClassName(get_class($msg));
        $fully_qualifed_name = $desc->getFullName();
        $this->type_url = GPBUtil::TYPE_URL_PREFIX.substr(
            $fully_qualifed_name, 1, strlen($fully_qualifed_name));
    }
824881
public function sendMusic (Type\Music $musicMessage)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $musicMessage->getType(),
                    ucfirst($musicMessage->getType()) => [
                        'Title' => $musicMessage->getTitle(),
                        'Description' => $musicMessage->getDescription(),
                        'MusicUrl' => $musicMessage->getSourceURL(),
                        'HQMusicUrl' => $musicMessage->getHighQualitySourceURL(),
                        'ThumbMediaId' => $musicMessage->getThumbnailID(),
                    ]
                ]
            )
        );
    }