DirectMessageChannel::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace Slack;
3
4
/**
5
 * Contains information about a direct message channel.
6
 */
7
class DirectMessageChannel extends ClientObject implements ChannelInterface
8
{
9
    /**
10
     * {@inheritDoc}
11
     */
12
    public function getId()
13
    {
14
        return $this->data['id'];
15
    }
16
17
    /**
18
     * Gets the time the channel was created.
19
     *
20
     * @return \DateTime The time the channel was created.
21
     */
22
    public function getTimeCreated()
23
    {
24
        $time = new \DateTime();
25
        $time->setTimestamp($this->data['created']);
26
        return $time;
27
    }
28
29
    /**
30
     * Gets the user the direct message channel is with.
31
     *
32
     * @return \React\Promise\PromiseInterface
33
     */
34
    public function getUser()
35
    {
36
        return $this->client->getUserById($this->data['user']);
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function close()
43
    {
44
        return $this->client->apiCall('im.close', [
45
            'channel' => $this->getId(),
46
        ])->then(function ($response) {
47
            return !isset($response['no_op']);
48
        });
49
    }
50
}
51