chatJoinRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 70
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 2
A revokeLink() 0 2 1
A accept() 0 2 1
A deny() 0 2 1
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\telegram\telegram;
6
use stdClass;
7
8
/**
9
 * Represents a join request sent to a chat.
10
 */
11
class chatJoinRequest extends types {
0 ignored issues
show
Bug introduced by
The type BPT\types\types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
    /** Keep all properties which has sub properties */
13
    private const subs = [
14
        'chat' => 'BPT\types\chat',
15
        'from' => 'BPT\types\user',
16
        'invite_link' => 'BPT\types\chatInviteLink',
17
    ];
18
19
    /** Chat to which the request was sent */
20
    public chat $chat;
21
22
    /** User that sent the join request */
23
    public user $from;
24
25
    /**
26
     * Identifier of a private chat with the user who sent the join request. This number may have more than 32
27
     * significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it
28
     * has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this
29
     * identifier. The bot can use this identifier for 5 minutes to send messages until the join request is
30
     * processed, assuming no other administrator contacted the user.
31
     */
32
    public int $user_chat_id;
33
34
    /** Date the request was sent in Unix time */
35
    public int $date;
36
37
    /** Optional. Bio of the user. */
38
    public null|string $bio = null;
39
40
    /** Optional. Chat invite link that was used by the user to send the join request */
41
    public null|chatInviteLink $invite_link = null;
42
43
44
    public function __construct(stdClass|null $object = null) {
45
        if ($object != null) {
46
            parent::__construct($object, self::subs);
47
        }
48
    }
49
50
    /**
51
     * Accept join request
52
     *
53
     * @param null|bool $answer
54
     *
55
     * @return responseError|bool
56
     */
57
    public function accept(bool $answer = null): responseError|bool {
58
        return telegram::approveChatJoinRequest($this->chat->id,$this->from->id, answer: $answer);
59
    }
60
61
    /**
62
     * Decline join request
63
     *
64
     * @param bool|null $answer
65
     *
66
     * @return responseError|bool
67
     */
68
    public function deny(bool $answer = null): responseError|bool {
69
        return telegram::declineChatJoinRequest($this->chat->id,$this->from->id, answer: $answer);
70
    }
71
72
    /**
73
     * Revoke invite link
74
     *
75
     * @param bool|null $answer
76
     *
77
     * @return responseError|bool
78
     */
79
    public function revokeLink(bool $answer = null): responseError|bool {
80
        return telegram::revokeChatInviteLink($this->invite_link->invite_link, $this->chat->id, answer: $answer);
81
    }
82
}
83