IterateDefinition::ids()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Habemus\Definition\Build;
5
6
use Habemus\Definition\Definition;
7
use Habemus\Definition\Identifiable\IdentifiableTrait;
8
use Habemus\Definition\MethodCall\CallableMethod;
9
use Habemus\Definition\MethodCall\CallableMethodTrait;
10
use Habemus\Definition\Sharing\Shareable;
11
use Habemus\Definition\Sharing\ShareableTrait;
12
use Habemus\Definition\Tag\Taggable;
13
use Habemus\Definition\Tag\TaggableTrait;
14
use Psr\Container\ContainerInterface;
15
use Traversable;
16
17
class IterateDefinition implements Definition, Shareable, CallableMethod, Taggable
18
{
19
    use IdentifiableTrait;
20
    use ShareableTrait;
21
    use CallableMethodTrait;
22
    use TaggableTrait;
23
24
    /**
25
     * @var string[]
26
     */
27
    protected $ids;
28
29
    public function __construct(string ...$id)
30
    {
31
        $this->ids = $id;
32
    }
33
34
    public function ids(): array
35
    {
36
        return $this->ids;
37
    }
38
39
    public function getConcrete(ContainerInterface $container): Traversable
40
    {
41
        foreach ($this->ids as $id) {
42
            yield $id => $container->get($id);
43
        }
44
    }
45
}
46