Passed
Push — master ( 4c2b59...061776 )
by Shahrad
02:09
created

ShippingQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 27
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A answer() 0 6 1
A subEntities() 0 5 1
1
<?php
2
3
namespace TelegramBot\Entities\Payments;
4
5
use TelegramBot\Entities\Response;
6
use TelegramBot\Entities\User;
7
use TelegramBot\Entity;
8
use TelegramBot\Request;
9
10
/**
11
 * Class ShippingQuery
12
 *
13
 * This object contains information about an incoming shipping query.
14
 *
15
 * @link https://core.telegram.org/bots/api#shippingquery
16
 *
17
 * @method string          getId()                  Unique query identifier
18
 * @method User            getFrom()                User who sent the query
19
 * @method string          getInvoicePayload()      Bot specified invoice payload
20
 * @method ShippingAddress getShippingAddress()     User specified shipping address
21
 **/
22
class ShippingQuery extends Entity
23
{
24
25
    /**
26
     * Answer this shipping query.
27
     *
28
     * @param bool $ok
29
     * @param array $data
30
     *
31
     * @return Response
32
     */
33
    public function answer(bool $ok, array $data = []): Response
34
    {
35
        return Request::answerShippingQuery(array_merge([
36
            'shipping_query_id' => $this->getId(),
37
            'ok' => $ok,
38
        ], $data));
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function subEntities(): array
45
    {
46
        return [
47
            'from' => User::class,
48
            'shipping_address' => ShippingAddress::class,
49
        ];
50
    }
51
52
}
53