Passed
Push — main ( 36dc31...e0778d )
by Miaad
10:46
created

contact::fullName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\constants\fields;
6
use BPT\telegram\request;
7
use stdClass;
8
9
/**
10
 * This object represents a phone contact.
11
 */
12
class contact 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 of properties which has sub properties */
14
    private const subs = [];
15
16
    /** Contact's phone number */
17
    public string $phone_number;
18
19
    /** Contact's first name */
20
    public string $first_name;
21
22
    /** Optional. Contact's last name */
23
    public null|string $last_name = null;
24
25
    /**
26
     * Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some
27
     * programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant
28
     * bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
29
     */
30
    public null|int $user_id = null;
31
32
    /** Optional. Additional data about the contact in the form of a vCard */
33
    public null|string $vcard = null;
34
35
36
    public function __construct(stdClass|null $object = null) {
37
        if ($object != null) {
38
            parent::__construct($object, self::subs);
39
        }
40
    }
41
42
    /**
43
     * Check if shared contact is for the sender user (useful for phone auth)
44
     *
45
     * @return bool
46
     */
47
    public function isUserPhone(): bool {
48
        return $this->user_id === request::catchFields(fields::USER_ID);
49
    }
50
51
    public function fullName (): string {
52
        return trim($this->first_name . ' ' . ($this->last_name ?? ''));
53
    }
54
}
55