Passed
Pull Request — master (#241)
by Dmitriy
02:20
created

DynamicReferencesArray   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A from() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Di;
6
7
use Yiisoft\Factory\Definition\DynamicReference;
8
use Yiisoft\Factory\Exception\InvalidConfigException;
9
10
final class DynamicReferencesArray
11
{
12
    /**
13
     * @param array $ids
14
     * @return array
15
     * @throws InvalidConfigException
16
     */
17 2
    static function from(array $ids)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19 2
        $references = [];
20
21 2
        foreach ($ids as $id) {
22 2
            if (!is_string($id)) {
23 1
                throw new InvalidConfigException('Values of an array must be string alias or class name.');
24
            }
25 2
            $references[] = DynamicReference::to($id);
26
        }
27
28 1
        return $references;
29
    }
30
}
31