Completed
Push — master ( a6a584...311c12 )
by Camilo
02:12
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 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4286
c 1
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 13 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

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