DirectMessageChannel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 44
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getTimeCreated() 0 6 1
A getUser() 0 4 1
A close() 0 8 1
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