Passed
Pull Request — develop (#1077)
by Marco
02:09
created

ShippingQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

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