Passed
Push — master ( df4cce...a240aa )
by
02:18
created

MockySender   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 85
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A leaveGroup() 0 4 1
A pushMessage() 0 5 1
A replyMessage() 0 5 1
A replyText() 0 6 1
A leaveRoom() 0 4 1
A multicast() 0 5 1
A getProfile() 0 4 1
A validateSignature() 0 5 1
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([
0 ignored issues
show
Bug Best Practice introduced by
The expression return new LINE\LINEBot\...ature' => $signature))) returns the type LINE\LINEBot\Response which is incompatible with the return type mandated by LineMob\Core\Sender\Send...ce::validateSignature() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
103
            '$body' => $body,
104
            '$signature' => $signature,
105
        ]));
106
    }
107
}
108