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

ReferencesArray::from()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Di;
6
7
use Yiisoft\Factory\Definition\Reference;
8
use Yiisoft\Factory\Exception\InvalidConfigException;
9
10
final class ReferencesArray
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[] = Reference::to($id);
26
        }
27
28 1
        return $references;
29
    }
30
}
31