Passed
Pull Request — master (#152)
by Andrii
27:36 queued 12:36
created

TagDefinition::addReferenceTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Di\Definitions;
6
7
use Psr\Container\ContainerInterface;
8
use Yiisoft\Factory\Definitions\DefinitionInterface;
9
10
class TagDefinition implements DefinitionInterface
11
{
12
    private array $references;
13
14
    public function __construct(array $ids)
15
    {
16
        $this->references = $ids;
17
    }
18
19
    public function resolve(ContainerInterface $container)
20
    {
21
        $results = [];
22
        foreach ($this->references as $id) {
23
            $results[] = $container->get($id);
24
        }
25
26
        return $results;
27
    }
28
29
    public function addReferenceTo(string $id): void
30
    {
31
        $this->references[$id] = $id;
32
    }
33
}
34