Completed
Push — master ( 23095d...54d687 )
by Danilo
02:12
created

Chat::getChatAdministrators()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace PhpBotFramework\Core;
4
5
trait Chat {
6
7
    /**
8
     * \addtogroup Api Api Methods
9
     * @{
10
     */
11
12
    /**
13
     * \brief A simple method for testing your bot's auth token.
14
     * \details Requires no parameters. Returns basic information about the bot in form of a User object. [Api reference](https://core.telegram.org/bots/api#getme)
15
     */
16
    public function getMe() {
17
18
        return $this->exec_curl_request('getMe?');
0 ignored issues
show
Bug introduced by
It seems like exec_curl_request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
19
20
    }
21
22
    /**
23
     * \brief Get info about a chat.
24
     * \details Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). [Api reference](https://core.telegram.org/bots/api#getchat)
25
     * @param Unique identifier for the target chat or username of the target supergroup or channel (in the format <code>@channelusername</code>)
26
     */
27
    public function getChat($_chat_id) {
28
29
        $parameters = [
30
            'chat_id' => $_chat_id,
31
        ];
32
33
        return $this->exec_curl_request('getChat?' . http_build_query($parameters));
0 ignored issues
show
Bug introduced by
It seems like exec_curl_request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
34
35
    }
36
37
    /**
38
     * \brief Use this method to get a list of administrators in a chat.
39
     * @param Unique identifier for the target chat or username of the target supergroup or channel (in the format <code>@channelusername</code>)
40
     * @return On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
41
     */
42
    public function getChatAdministrators($_chat_id) {
43
44
        $parameters = [
45
            'chat_id' => $_chat_id,
46
        ];
47
48
        return $this->exec_curl_request('getChatAdministrators?' . http_build_query($parameters));
0 ignored issues
show
Bug introduced by
It seems like exec_curl_request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
49
50
    }
51
52
    /** @} */
53
54
}
55