Passed
Push — main ( 8c6c55...1af2d8 )
by Miaad
12:23 queued 14s
created

usersShared::getInfo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\telegram\telegram;
6
use stdClass;
7
8
/**
9
 * This object contains information about the users whose identifiers were shared with the bot using a
10
 * KeyboardButtonRequestUsers button.
11
 */
12
class usersShared 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...
13
    /** Keep all properties which has sub properties */
14
    private const subs = [];
15
16
    /** Identifier of the request */
17
    public int $request_id;
18
19
    /**
20
     * Identifiers of the shared users. These numbers may have more than 32 significant bits and some programming
21
     * languages may have difficulty/silent defects in interpreting them. But they have at most 52 significant bits,
22
     * so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not
23
     * have access to the users and could be unable to use these identifiers, unless the users are already known to
24
     * the bot by some other means.
25
     * @var int[]
26
     */
27
    public array $user_ids;
28
29
30
    public function __construct(stdClass|null $object = null) {
31
        if ($object != null) {
32
            parent::__construct($object, self::subs);
33
        }
34
    }
35
36
    /**
37
     * Get shared user info by using getChat method
38
     *
39
     * @param bool|null $answer
40
     */
41
    public function getInfo (bool $answer = null): array {
42
        $result = [];
43
        foreach ($this->user_ids as $user_id) {
44
            $result[$user_id] = telegram::getChat($user_id, answer: $answer);
45
        }
46
        return $result;
47
    }
48
}
49