Completed
Push — 811-helper_for_media_groups ( c599d5...2499c6 )
by Armando
02:40
created

UserProfilePhotos::subEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
     * 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
    public function getPhotos()
40
    {
41
        $all_photos = [];
42
43
        if ($these_photos = $this->getProperty('photos')) {
44
            foreach ($these_photos as $photos) {
45
                $new_photos = [];
46
                foreach ($photos as $photo) {
47
                    $new_photos[] = new PhotoSize($photo);
48
                }
49
                $all_photos[] = $new_photos;
50
            }
51
        }
52
53
        return $all_photos;
54
    }
55
}
56