Completed
Push — bot_api_4.0_passport ( 3dbf45 )
by Armando
02:40
created

EncryptedPassportElement::subEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities\TelegramPassport;
12
13
use Longman\TelegramBot\Entities\Entity;
14
15
/**
16
 * Class EncryptedPassportElement
17
 *
18
 * Contains information about documents or other Telegram Passport elements shared with the bot by the user.
19
 *
20
 * @link https://core.telegram.org/bots/api#encryptedpassportelement
21
 *
22
 * @method string       getType()        Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”.
23
 * @method string       getData()        Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “identity_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials.
24
 * @method string       getPhoneNumber() Optional. User's verified phone number, available only for “phone_number” type
25
 * @method string       getEmail()       Optional. User's verified email address, available only for “email” type
26
 * @method PassportFile getFrontSide()   Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
27
 * @method PassportFile getReverseSide() Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
28
 * @method PassportFile getSelfie()      Optional. Encrypted file with the selfie of the user holding a document, provided by the user;
29
 *                                       available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
30
 **/
31
class EncryptedPassportElement extends Entity
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function subEntities()
37
    {
38
        return [
39
            'files'        => PassportFile::class,
40
            'front_side'   => PassportFile::class,
41
            'reverse_side' => PassportFile::class,
42
            'selfie'       => PassportFile::class,
43
        ];
44
    }
45
46
    /**
47
     * Array with information about documents and other Telegram Passport elements that was shared with the bot
48
     *
49
     * This method overrides the default getFiles method
50
     * and returns a nice array of PassportFile objects.
51
     *
52
     * @return null|PassportFile[]
53
     */
54
    public function getFiles()
55
    {
56
        $pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'files');
57
58
        return empty($pretty_array) ? null : $pretty_array;
59
    }
60
}
61