Passed
Pull Request — master (#312)
by Sergei
14:16 queued 11:32
created

ArrayIteratorTrait::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Trait;
6
7
use ArrayIterator;
8
use IteratorAggregate;
9
10
/**
11
 * Trait to implement {@see IteratorAggregate} for ActiveRecord.
12
 *
13
 * @method array getAttributes(array|null $names = null, array $except = [])
14
 * @see ActiveRecordInterface::getAttributes() for more info.
15
 */
16
trait ArrayIteratorTrait
17
{
18
    /**
19
     * Returns an iterator for traversing the attributes in the ActiveRecord.
20
     *
21
     * This method is required by the interface {@see IteratorAggregate}.
22
     *
23
     * @return ArrayIterator an iterator for traversing the items in the list.
24
     */
25
    public function getIterator(): ArrayIterator
26
    {
27
        $attributes = $this->getAttributes();
28
29
        return new ArrayIterator($attributes);
30
    }
31
}
32