CollectionFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 9
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\AuthClient\Factory;
6
7
use Psr\Container\ContainerInterface;
8
use Yiisoft\Yii\AuthClient\Collection;
9
10
class CollectionFactory
11
{
12
    private array $clients;
13
14
    public function __construct(array $clients = [])
15
    {
16
        $this->clients = $clients;
17
    }
18
19
    public function __invoke(ContainerInterface $container): Collection
20
    {
21
        $clients = [];
22
        foreach ($this->clients as $name => $client) {
23
            if (!is_string($name)) {
24
                throw new \InvalidArgumentException('Client name must be set.');
25
            }
26
            $clients[$name] = $container->get($client);
27
        }
28
        return new Collection($clients);
29
    }
30
}
31