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

UserProfilePhotosArray   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 30
ccs 8
cts 12
cp 0.6667
rs 10
c 5
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
A traverseObject() 0 6 2
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