Completed
Pull Request — master (#44)
by Alberto
02:53
created

buildStubs.php ➔ buildStubs()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 1
dl 0
loc 15
ccs 7
cts 7
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Factory;
5
6
use Moka\Exception\InvalidArgumentException;
7
use Moka\Stub\StubInterface;
8
use Moka\Stub\StubSet;
9
10
/**
11
 * @param array $namesWithValues
12
 * @return StubSet|StubInterface[]
13
 *
14
 * @throws InvalidArgumentException
15
 */
16
function buildStubs(array $namesWithValues): StubSet
17
{
18 81
    $stubSet = new StubSet();
19 81
    foreach ($namesWithValues as $name => $value) {
20
        try {
21 81
            $stub = buildStub($name, $value);
22 1
        } catch (\Error $error) {
23 1
            throw new InvalidArgumentException($error->getMessage());
24
        }
25
26 80
        $stubSet->add($stub);
27
    }
28
29 80
    return $stubSet;
30
}
31