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

InlineKeyboardButtonArray::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 1
Bugs 0 Features 0
Metric Value
c 1
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\Telegram\Types\InlineKeyboardButton;
9
use unreal4u\TelegramAPI\Interfaces\CustomArrayType;
10
use Psr\Log\LoggerInterface;
11
12
/**
13
 * Mockup class to generate a real telegram update representation
14
 */
15
class InlineKeyboardButtonArray extends CustomType implements CustomArrayType
16
{
17
    public $data = [];
18
19
    public function __construct(array $data = null, LoggerInterface $logger = null)
20
    {
21
        if (!empty($data)) {
22
            foreach ($data as $id => $photo) {
23
                $this->data[$id] = new InlineKeyboardButton();
24
            }
25
        }
26
    }
27
28
    /**
29
     * Traverses through our $data, yielding the result set
30
     *
31
     * @return \Generator
32
     */
33
    public function traverseObject()
34
    {
35
        foreach ($this->data as $inlineKeyboardButton) {
36
            yield $inlineKeyboardButton;
37
        }
38
    }
39
}
40