forked from thenbsp/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticle.php
More file actions
47 lines (38 loc) · 830 Bytes
/
Article.php
File metadata and controls
47 lines (38 loc) · 830 Bytes
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
45
46
47
<?php
namespace Thenbsp\Wechat\Message\Entity;
use Thenbsp\Wechat\Message\Entity;
class Article extends Entity
{
/**
* 图文列表
*/
protected $items = array();
/**
* 添加图文
*/
public function addItem(ArticleItem $item)
{
$this->items[] = $item;
}
/**
* 消息内容
*/
public function getBody()
{
$body = array();
foreach( $this->items as $item ) {
$body['item'][] = $item->getBody();
}
$count = isset($body['item'])
? count($body['item'])
: 0;
return array('Articles' => $body, 'ArticleCount' => $count);
}
/**
* 消息类型
*/
public function getType()
{
return 'news';
}
}