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

InlineKeyboardButtonArray   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 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\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