Message::setType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace erjanmx\nambaone;
4
5
class Message
6
{
7
    const CONTENT_TYPE_AUDIO_MP4 = 'audio/mp4';
8
    const CONTENT_TYPE_TEXT_PLAIN = 'text/plain';
9
    const CONTENT_TYPE_MEDIA_IMAGE = 'media/image';
10
    const CONTENT_TYPE_CONTACT_JSON = 'contact/json';
11
    const CONTENT_TYPE_STICKER_JSON = 'sticker/json';
12
    const CONTENT_TYPE_LOCATION_JSON = 'location/json';
13
14
    /**
15
     * @var Client
16
     */
17
    protected $client;
18
19
    /**
20
     * @var string Message type
21
     */
22
    protected $type;
23
24
    /**
25
     * @var string Message content
26
     */
27
    protected $content;
28
29
    /**
30
     * @var integer 
31
     */
32
    protected $chat_id;
33
34
    /**
35
     * Message constructor.
36
     * @param Client $client
37
     */
38
    function __construct(Client $client)
39
    {
40
        $this->client = $client;
41
        
42
        $this->setType(self::CONTENT_TYPE_TEXT_PLAIN);
43
    }
44
45
    /**
46
     * @param $chat_id
47
     * @return $this
48
     */
49
    public function to($chat_id)
50
    {
51
        $this->setChatId($chat_id);
52
53
        return $this;
54
    }
55
56
    /**
57
     * @param $chat_id
58
     * @return $this
59
     */
60
    public function setChatId($chat_id)
61
    {
62
        $this->chat_id = $chat_id;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getChatId()
71
    {
72
        return $this->chat_id;
73
    }
74
75
    /**
76
     * @param $type
77
     * @return $this
78
     */
79
    public function setType($type)
80
    {
81
        $this->type = $type;
82
83
        return $this;
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    public function getType()
90
    {
91
        return $this->type;
92
    }
93
94
    /**
95
     * @param $content
96
     * @return $this
97
     */
98
    public function setContent($content)
99
    {
100
        $this->content = $content;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getContent()
109
    {
110
        return $this->content;
111
    }
112
113
    /**
114
     * @param null $content
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $content is correct as it would always require null to be passed?
Loading history...
115
     * @return mixed
116
     */
117
    public function send($content = null)
118
    {
119
        if (! is_null($content))
120
            $this->setContent($content);
121
122
        return $this->client->api->sendMessage($this);
123
    }
124
}
125