TextMessageContent.php
949 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Weasy\External\Api\Struct\Message;
use Weasy\External\Utils\Error\QyApiError;
use Weasy\External\Utils\Utils;
class TextMessageContent
{
public $msgtype = "text";
private $content = null; // string
/**
* TextMessageContent constructor.
*
* @param null $content
*/
public function __construct($content = null)
{
$this->content = $content;
}
/**
* @throws QyApiError
*/
public function CheckMessageSendArgs()
{
$len = strlen($this->content);
if ($len == 0 || $len > 2048) {
throw new QyApiError("invalid content length " . $len);
}
}
/**
* @param $arr
*/
public function MessageContent2Array(&$arr)
{
Utils::setIfNotNull($this->msgtype, "msgtype", $arr);
$contentArr = array("content" => $this->content);
Utils::setIfNotNull($contentArr, $this->msgtype, $arr);
}
}