UserProfilePhotos   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subEntities() 0 4 1
A getPhotos() 0 13 3
1
<?php
2
3
4
namespace TelegramBot\Entities;
5
6
use TelegramBot\Entity;
7
8
/**
9
 * Class UserProfilePhotos
10
 *
11
 * @link https://core.telegram.org/bots/api#userprofilephotos
12
 *
13
 * @method int getTotalCount() Total number of profile pictures the target user has
14
 */
15
class UserProfilePhotos extends Entity
16
{
17
18
    /**
19
     * Requested profile pictures (in up to 4 sizes each)
20
     *
21
     * This method overrides the default getPhotos method and returns a nice array
22
     *
23
     * @return PhotoSize[][]
24
     */
25
    public function getPhotos(): array
26
    {
27
        $all_photos = [];
28
29
        if ($these_photos = $this->getProperty('photos')) {
30
            foreach ($these_photos as $photos) {
31
                $all_photos[] = array_map(function ($photo) {
32
                    return new PhotoSize($photo);
33
                }, $photos);
34
            }
35
        }
36
37
        return $all_photos;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    protected function subEntities(): array
44
    {
45
        return [
46
            'photos' => PhotoSize::class,
47
        ];
48
    }
49
50
}
51