createContainerFromIncludedFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Roave\BehatPsrContainer;
5
6
use Psr\Container\ContainerInterface;
7
8
final class ContainerFactory
9
{
10
    /**
11
     * @param string $containerFile
12
     * @return ContainerInterface
13
     * @throws \RuntimeException
14
     */
15 2
    public static function createContainerFromIncludedFile(string $containerFile) : ContainerInterface
16
    {
17
        /** @noinspection PhpIncludeInspection */
18 2
        $container = require $containerFile;
19
20 2
        if (!$container instanceof ContainerInterface) {
21 1
            throw Exception\NotAPsrContainer::fromAnythingButAPsrContainer($containerFile, $container);
22
        }
23
24 1
        return $container;
25
    }
26
}
27