Failed Conditions
Push — master ( 8fb951...fb1394 )
by Arnold
03:15
created

EntryLoader::prepareNext()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Container\Loader;
6
7
use function Jasny\expect_type;
8
9
/**
10
 * Load entries from declaration PHP files
11
 */
12
class EntryLoader extends AbstractLoader
13
{
14
    /**
15
     * Load new entries
16
     *
17
     * @return void
18
     */
19 8
    protected function prepareNext(): void
20
    {
21 8
        if (!$this->items->valid()) {
22 2
            return;
23
        }
24
25 6
        $file = $this->items->current();
26
27 6
        $entries = include $file;
28 6
        expect_type($entries, 'array', \UnexpectedValueException::class,
29 6
            "Failed to load container entries from '$file': Invalid or no return value");
30
31 6
        $this->entries = new \ArrayIterator($entries);
32
33 6
        $this->items->next();
34 6
    }
35
}
36