Passed
Pull Request — master (#14)
by
10:26
created

Sender::pushMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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([
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...
104
            '$body' => $body,
105
            '$signature' => $signature,
106
        ]));
107
    }
108
}
109