-
Notifications
You must be signed in to change notification settings - Fork 172
/
UpdatesArray.php
39 lines (33 loc) · 903 Bytes
/
UpdatesArray.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types = 1);
namespace unreal4u\Telegram\Types\Custom;
use unreal4u\Abstracts\TelegramTypes;
use unreal4u\Interfaces\CustomArrayType;
use unreal4u\Telegram\Types\Update;
/**
* Mockup class to generate a real telegram update representation
*/
class UpdatesArray extends TelegramTypes implements CustomArrayType
{
public $data = [];
public function __construct(array $data = null)
{
if (!empty($data)) {
foreach ($data as $telegramResponse) {
// Create an actual Update object and fill the array
$this->data[] = new Update($telegramResponse);
}
}
}
/**
* Traverses through our $data, yielding the result set
*
* @return \Generator
*/
public function traverseObject()
{
foreach ($this->data as $update) {
yield $update;
}
}
}