Completed
Push — master ( 91bd85...f52cfe )
by Camilo
02:46
created

TraversableCustomType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 2
cts 5
cp 0.4
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 4 1
A traverseObject() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Abstracts;
6
7
use ArrayIterator;
8
use Generator;
9
use IteratorAggregate;
10
use Traversable;
11
12
/**
13
 * Class TraversableCustomType
14
 * @package unreal4u\TelegramAPI\Abstracts
15
 */
16
abstract class TraversableCustomType extends CustomType implements IteratorAggregate
17
{
18 4
    public function getIterator(): Traversable
19
    {
20 4
        return new ArrayIterator($this->data);
21
    }
22
23
    /**
24
     * Traverses through our $data, yielding the result set, can return any type of object
25
     * @return Generator|TelegramTypes
26
     */
27
    final public function traverseObject(): Generator
28
    {
29
        yield from $this->data;
30
    }
31
}
32