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

UpdatesArray   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
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\Update;
10
use Psr\Log\LoggerInterface;
11
12
/**
13
 * Mockup class to generate a real telegram update representation
14
 */
15
class UpdatesArray extends CustomType implements CustomArrayType
16
{
17
    public $data = [];
18
19 2
    public function __construct(array $data = null, LoggerInterface $logger = null)
20
    {
21 2
        if (!empty($data)) {
22 1
            foreach ($data as $telegramResponse) {
23
                // Create an actual Update object and fill the array
24 1
                $this->data[] = new Update($telegramResponse, $logger);
25
            }
26
        }
27 2
    }
28
29
    /**
30
     * Traverses through our $data, yielding the result set
31
     *
32
     * @return \Generator
33
     */
34 1
    public function traverseObject()
35
    {
36 1
        foreach ($this->data as $update) {
37 1
            yield $update;
38
        }
39 1
    }
40
}
41