UserProfilePhotos::subEntities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the TelegramBot package.
5
 *
6
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Longman\TelegramBot\Entities;
13
14
/**
15
 * Class UserProfilePhotos
16
 *
17
 * @link https://core.telegram.org/bots/api#userprofilephotos
18
 *
19
 * @method int getTotalCount() Total number of profile pictures the target user has
20
 */
21
class UserProfilePhotos extends Entity
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    protected function subEntities(): array
27
    {
28
        return [
29 1
            'photos' => PhotoSize::class,
30
        ];
31
    }
32
33
    /**
34
     * Requested profile pictures (in up to 4 sizes each)
35
     *
36
     * This method overrides the default getPhotos method and returns a nice array
37
     *
38
     * @return PhotoSize[][]
39
     */
40 1
    public function getPhotos(): array
41
    {
42 1
        $all_photos = [];
43
44 1
        if ($these_photos = $this->getProperty('photos')) {
45 1
            foreach ($these_photos as $photos) {
46 1
                $all_photos[] = array_map(function ($photo) {
47 1
                    return new PhotoSize($photo);
48 1
                }, $photos);
49
            }
50
        }
51
52 1
        return $all_photos;
53
    }
54
}
55