Completed
Push — develop ( 32ebf1...b1a895 )
by
unknown
15:09
created

UserProfilePhotos::__construct()   D

Complexity

Conditions 10
Paths 22

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 10.2368

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 25
rs 4.8196
ccs 13
cts 15
cp 0.8667
cc 10
eloc 15
nc 22
nop 1
crap 10.2368

1 Method

Rating   Name   Duplication   Size   Complexity  
A UserProfilePhotos::getPhotos() 0 16 4

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 UserProfilePhotos
15
 *
16
 * @link https://core.telegram.org/bots/api#userprofilephotos
17
 *
18
 * @method int getTotalCount() Total number of profile pictures the target user has
19
 */
20
class UserProfilePhotos extends Entity
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function subEntities()
26
    {
27
        return [
28
            'photos' => PhotoSize::class,
29
        ];
30
    }
31
32
    /**
33 1
     * Requested profile pictures (in up to 4 sizes each)
34
     *
35
     * This method overrides the default getPhotos method and returns a nice array
36 1
     *
37 1
     * @return PhotoSize[]
38
     */
39
    public function getPhotos()
40 1
    {
41 1
        $all_photos = [];
42
43
        if ($these_photos = $this->getProperty('photos')) {
44
            foreach ($these_photos as $photos) {
45 1
                $new_photos = [];
46 1
                foreach ($photos as $photo) {
47 1
                    $new_photos[] = new PhotoSize($photo);
48 1
                }
49 1
                $all_photos[] = $new_photos;
50
            }
51
        }
52 1
53
        return $all_photos;
54
    }
55
}
56