Completed
Push — draft ( f5c2f2...2c1ae4 )
by Nikolay
02:24
created

ShippingOption::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\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
    public static function create(string $id, string $title, array $prices)
41
    {
42
        $instance = new self();
43
        $instance->id = $id;
44
        $instance->title = $title;
45
        $instance->prices = $prices;
46
    }
47
48
    /**
49
     * @param LabeledPriceType $price
50
     */
51
    public function addPrice(LabeledPriceType $price)
52
    {
53
        $this->prices[] = $price;
54
    }
55
}
56