Completed
Push — bot_api_3.2 ( e6ffc0 )
by Armando
18:30
created

StickerSet::getStickers()   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 0
Metric Value
dl 16
loc 16
c 0
b 0
f 0
ccs 0
cts 14
cp 0
rs 9.2
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;
12
13
/**
14
 * Class StickerSet
15
 *
16
 * @link https://core.telegram.org/bots/api#stickerset
17
 *
18
 * @method string getName()          Sticker set name
19
 * @method string getTitle()         Sticker set title
20
 * @method bool   getContainsMasks() True, if the sticker set contains masks
21
 */
22 View Code Duplication
class StickerSet 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...
23
{
24
    /**
25
     * List of all set stickers
26
     *
27
     * This method overrides the default getStickers method and returns a nice array
28
     *
29
     * @return Sticker[]
30
     */
31
    public function getStickers()
32
    {
33
        $all_stickers = [];
34
35
        if ($these_stickers = $this->getProperty('stickers')) {
36
            foreach ($these_stickers as $stickers) {
37
                $new_stickers = [];
38
                foreach ($stickers as $sticker) {
39
                    $new_stickers[] = new Sticker($sticker);
40
                }
41
                $all_stickers[] = $new_stickers;
42
            }
43
        }
44
45
        return $all_stickers;
46
    }
47
}
48