Completed
Push — master ( e7303e...8fbc07 )
by Armando
01:58
created

StickerSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 26
loc 26
ccs 0
cts 14
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStickers() 16 16 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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