Completed
Push — master ( e7303e...8fbc07 )
by Armando
02:05 queued 25s
created

ShippingOption::getPrices()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 16
loc 16
ccs 0
cts 14
cp 0
rs 9.2
c 1
b 0
f 0
cc 4
eloc 9
nc 2
nop 0
crap 20
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities\Payments;
12
13
use Longman\TelegramBot\Entities\Entity;
14
15
/**
16
 * Class ShippingOption
17
 *
18
 * This object represents one shipping option.
19
 *
20
 * @link https://core.telegram.org/bots/api#shippingoption
21
 *
22
 * @method string getId()    Shipping option identifier
23
 * @method string getTitle() Option title
24
 **/
25 View Code Duplication
class ShippingOption extends Entity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function subEntities()
31
    {
32
        return [
33
            'prices' => LabeledPrice::class,
34
        ];
35
    }
36
37
    /**
38
     * List of price portions
39
     *
40
     * This method overrides the default getPrices method and returns a nice array
41
     *
42
     * @return LabeledPrice[]
43
     */
44
    public function getPrices()
45
    {
46
        $all_prices = [];
47
48
        if ($these_prices = $this->getProperty('prices')) {
49
            foreach ($these_prices as $prices) {
50
                $new_prices = [];
51
                foreach ($prices as $price) {
52
                    $new_prices[] = new LabeledPrice($price);
53
                }
54
                $all_prices[] = $new_prices;
55
            }
56
        }
57
58
        return $all_prices;
59
    }
60
}
61