Passed
Push — master ( 45bce2...5a8248 )
by Nikolay
03:20
created

SetPassportDataErrorsMethod::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Type\PassportElementError\PassportElementErrorType;
8
9
/**
10
 * Class SetPassportDataErrorsMethod.
11
 *
12
 * Informs a user that some of the Telegram Passport elements they provided contains errors.
13
 * The user will not be able to re-submit their Passport to you until the errors are fixed
14
 * (the contents of the field for which you returned the error must change). Returns True on success.
15
 *
16
 * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason.
17
 * For example, if a birthday date seems invalid, a submitted document is blurry,
18
 * a scan shows evidence of tampering, etc.
19
 * Supply some details in the error message to make sure the user knows how to correct the issues.
20
 *
21
 * @see https://core.telegram.org/bots/api#setpassportdataerrors
22
 * @see https://core.telegram.org/passport
23
 */
24
class SetPassportDataErrorsMethod
25
{
26
    /**
27
     * User identifier.
28
     *
29
     * @var int
30
     */
31
    public $userId;
32
33
    /**
34
     * A JSON-serialized array describing the errors.
35
     *
36
     * @var PassportElementErrorType[]
37
     */
38
    public $errors;
39
40
    /**
41
     * SetPassportDataErrorsMethod constructor.
42
     *
43
     * @param int $userId
44
     * @param PassportElementErrorType[]
45
     * @param array $errors
46
     *
47
     * @return SetPassportDataErrorsMethod
48
     */
49 27
    public static function create(int $userId, array $errors): SetPassportDataErrorsMethod
50
    {
51 27
        $instance = new static();
52 27
        $instance->userId = $userId;
53 27
        $instance->errors = $errors;
54
55 27
        return $instance;
56
    }
57
}
58