UserProfilePhotos   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subEntities() 0 6 1
A getPhotos() 0 16 4
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 1
    protected function subEntities()
26
    {
27
        return [
28 1
            'photos' => PhotoSize::class,
29
        ];
30
    }
31
32
    /**
33
     * Requested profile pictures (in up to 4 sizes each)
34
     *
35
     * This method overrides the default getPhotos method and returns a nice array
36
     *
37
     * @return PhotoSize[]
38
     */
39 1
    public function getPhotos()
40
    {
41 1
        $all_photos = [];
42
43 1
        if ($these_photos = $this->getProperty('photos')) {
44 1
            foreach ($these_photos as $photos) {
45 1
                $new_photos = [];
46 1
                foreach ($photos as $photo) {
47 1
                    $new_photos[] = new PhotoSize($photo);
48
                }
49 1
                $all_photos[] = $new_photos;
50
            }
51
        }
52
53 1
        return $all_photos;
54
    }
55
}
56