Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

ShippingOption   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 50
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addPrice() 0 5 1
A create() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type;
6
7
/**
8
 * Class ShippingOption.
9
 *
10
 * @see https://core.telegram.org/bots/api#shippingoption
11
 */
12
class ShippingOption
13
{
14
    /**
15
     * Shipping option identifier.
16
     *
17
     * @var string
18
     */
19
    public $id;
20
21
    /**
22
     * Option title.
23
     *
24
     * @var string
25
     */
26
    public $title;
27
28
    /**
29
     * List of price portions.
30
     *
31
     * @var LabeledPriceType[]
32
     */
33
    public $prices;
34
35
    /**
36
     * @param string $id
37
     * @param string $title
38
     * @param array  $prices
39
     *
40
     * @return ShippingOption
41
     */
42
    public static function create(string $id, string $title, array $prices): ShippingOption
43
    {
44
        $instance = new static();
45
        $instance->id = $id;
46
        $instance->title = $title;
47
        $instance->prices = $prices;
48
49
        return $instance;
50
    }
51
52
    /**
53
     * @param LabeledPriceType $price
54
     *
55
     * @return ShippingOption
56
     */
57
    public function addPrice(LabeledPriceType $price): ShippingOption
58
    {
59
        $this->prices[] = $price;
60
61
        return $this;
62
    }
63
}
64