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