Location.php
954 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
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: Hanson
* Date: 2016/12/16
* Time: 21:13
*/
namespace Hanson\Robot\Message\Entity;
use Hanson\Robot\Message\MessageInterface;
class Location extends Message implements MessageInterface
{
/**
* @var string 位置链接
*/
public $url;
public function __construct($msg)
{
parent::__construct($msg);
$this->make();
}
/**
* 判断是否位置消息
*
* @param $content
* @return bool
*/
public static function isLocation($content)
{
return str_contains($content['Content'], 'webwxgetpubliclinkimg') && $content['Url'];
}
/**
* 设置位置文字信息
*/
private function setLocationText()
{
$this->content = current(explode(":\n", $this->msg['Content']));
$this->url = $this->msg['Url'];
}
public function make()
{
$this->setLocationText();
}
}