Completed
Push — master ( 7c39f2...831177 )
by Jeroen
04:12
created

IrcChannel::getTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Jerodev\PhpIrcClient;
4
5
class IrcChannel
6
{
7
    /** @var string */
8
    private $name;
9
10
    /** @var null|string */
11
    private $topic;
12
13
    /** @var string[] */
14
    private $users;
15
16
    public function __construct(string $name)
17
    {
18
        if ($name[0] !== '#') {
19
            $name = "#$name";
20
        }
21
        $this->name = $name;
22
        $this->users = [];
23
    }
24
25
    /** 
26
     *  Fetch the name of the channel, including the `#`
27
     *
28
     *  @return string
29
     */
30
    public function getName(): string
31
    {
32
        return $this->name;
33
    }
34
    
35
    /**
36
     *  Get the current channel topic.
37
     *
38
     *  @return null|string
39
     */
40
    public function getTopic()
41
    {
42
        return $this->topic;
43
    }
44
45
    /**
46
     *  Fetch the list of users currently on this channel.
47
     *
48
     *  @return string[]
49
     */
50
    public function getUsers(): array
51
    {
52
        return $this->users;
53
    }
54
55
    /**
56
     *  Set the current channel topic.
57
     *
58
     *  @param string $topic The topic
59
     */
60
    public function setTopic(string $topic): void
61
    {
62
        $this->topic = $topic;
63
    }
64
65
    /**
66
     *  Set the list of active users on the channel.
67
     *
68
     *  @param string[] $users An array of user names.
69
     */
70
    public function setUsers(array $users): void
71
    {
72
        $this->users = $users;
73
    }
74
}
75