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

UpdatesArray::traverseObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 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