Passed
Pull Request — master (#312)
by Sergei
15:36 queued 02:10
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
 * @method array getAttributes(array|null $names = null, array $except = [])
12
 * @see ActiveRecordInterface::getAttributes() for more info.
13
 */
14
trait ArrayIteratorTrait
15
{
16
    /**
17
     * Returns an iterator for traversing the attributes in the ActiveRecord.
18
     *
19
     * This method is required by the interface {@see IteratorAggregate}.
20
     *
21
     * @return ArrayIterator an iterator for traversing the items in the list.
22
     */
23
    public function getIterator(): ArrayIterator
24
    {
25
        $attributes = $this->getAttributes();
26
27
        return new ArrayIterator($attributes);
28
    }
29
}
30