| Total Complexity | 7 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 |
||
| 73 | } |
||
| 74 | } |
||
| 75 |