1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LineMob package. |
5
|
|
|
* |
6
|
|
|
* (c) Ishmael Doss <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LineMob\Core\Mocky; |
13
|
|
|
|
14
|
|
|
use LINE\LINEBot\MessageBuilder; |
15
|
|
|
use LINE\LINEBot\Response; |
16
|
|
|
use LineMob\Core\Sender\SenderInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Ishmael Doss <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Sender implements SenderInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function getProfile($userId) |
27
|
|
|
{ |
28
|
|
|
return new Response(200, json_encode([ |
29
|
|
|
'$userId' => $userId, |
30
|
|
|
])); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function replyMessage($replyToken, MessageBuilder $messageBuilder) |
37
|
|
|
{ |
38
|
|
|
return new Response(200, json_encode([ |
39
|
|
|
'$replyToken' => $replyToken, |
40
|
|
|
'$messageBuilder' => $messageBuilder->buildMessage(), |
41
|
|
|
])); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function replyText($replyToken, $text, $extraTexts = null) |
48
|
|
|
{ |
49
|
|
|
return new Response(200, json_encode([ |
50
|
|
|
'$replyToken' => $replyToken, |
51
|
|
|
'$text' => $text, |
52
|
|
|
'$extraTexts' => $extraTexts, |
53
|
|
|
])); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function pushMessage($to, MessageBuilder $messageBuilder) |
60
|
|
|
{ |
61
|
|
|
return new Response(200, json_encode([ |
62
|
|
|
'$to' => $to, |
63
|
|
|
'$messageBuilder' => $messageBuilder->buildMessage(), |
64
|
|
|
])); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
|
|
public function multicast(array $tos, MessageBuilder $messageBuilder) |
71
|
|
|
{ |
72
|
|
|
return new Response(200, json_encode([ |
73
|
|
|
'$tos' => $tos, |
74
|
|
|
'$messageBuilder' => $messageBuilder->buildMessage(), |
75
|
|
|
])); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
|
|
public function leaveGroup($groupId) |
82
|
|
|
{ |
83
|
|
|
return new Response(200, json_encode([ |
84
|
|
|
'$groupId' => $groupId, |
85
|
|
|
])); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
|
|
public function leaveRoom($roomId) |
92
|
|
|
{ |
93
|
|
|
return new Response(200, json_encode([ |
94
|
|
|
'$roomId' => $roomId, |
95
|
|
|
])); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* {@inheritdoc} |
100
|
|
|
*/ |
101
|
|
|
public function validateSignature($body, $signature) |
102
|
|
|
{ |
103
|
|
|
return new Response(200, json_encode([ |
|
|
|
|
104
|
|
|
'$body' => $body, |
105
|
|
|
'$signature' => $signature, |
106
|
|
|
])); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: