Completed
Push — master ( e9be36...9488e8 )
by Camilo
04:57
created

UserProfilePhotosArray::traverseObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 6
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types\Custom;
6
7
use unreal4u\TelegramAPI\Abstracts\CustomType;
8
use unreal4u\TelegramAPI\Interfaces\CustomArrayType;
9
use unreal4u\TelegramAPI\Telegram\Types\PhotoSize;
10
use Psr\Log\LoggerInterface;
11
12
/**
13
 * Mockup class to generate a real telegram update representation
14
 */
15
class UserProfilePhotosArray extends CustomType implements CustomArrayType
16
{
17
    public $data = [];
18
19 3
    public function __construct(array $data = null, LoggerInterface $logger = null)
20
    {
21 3
        if (!empty($data)) {
22 2
            $i = 0;
23 2
            foreach ($data as $telegramResponse) {
24 2
                foreach ($telegramResponse as $photoSize) {
25
                    // Create an actual PhotoSize object and fill the array
26 2
                    $this->data[$i][] = new PhotoSize($photoSize, $logger);
27
                }
28 2
                $i++;
29
            }
30
        }
31 3
    }
32
33
    /**
34
     * Traverses through our $data, yielding the result set
35
     *
36
     * @return \Generator
37
     */
38
    public function traverseObject()
39
    {
40
        foreach ($this->data as $data) {
41
            yield $data;
42
        }
43
    }
44
}
45