EntryLoader::prepareNext()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

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