Passed
Push — master ( b674ac...2bc77e )
by Kirill
04:21
created

SelectiveReader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A each() 0 11 3
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Attributes\Composite;
13
14
final class SelectiveReader extends Composite
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected function each(callable $resolver): iterable
20
    {
21
        foreach ($this->readers as $reader) {
22
            $result = $this->iterableToArray($resolver($reader));
23
24
            if (\count($result) > 0) {
25
                return $result;
26
            }
27
        }
28
29
        return [];
30
    }
31
}
32