Passed
Push — master ( 2dffc4...9bc131 )
by Alexander
02:20
created

MergeSchemaProvider::read()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.6111
cc 5
nc 5
nop 1
crap 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Schema\Provider\Support;
6
7
use RuntimeException;
8
use Yiisoft\Yii\Cycle\Schema\SchemaProviderInterface;
9
10
/**
11
 * A class for working with a group of schema providers.
12
 * Parts of the schema are read from all providers and merged into one.
13
 */
14
final class MergeSchemaProvider extends BaseProviderCollector
15
{
16
    protected const IS_SEQUENCE_PIPELINE = false;
17
18 16
    public function read(?SchemaProviderInterface $nextProvider = null): ?array
19
    {
20 16
        if ($this->providers === null) {
21 1
            throw new RuntimeException(self::class . ' is not configured.');
22
        }
23 15
        $parts = [];
24 15
        foreach ($this->providers as $provider) {
25 12
            $parts[] = $provider->read();
26
        }
27
28 13
        $schema = (new SchemaMerger())->merge(...$parts);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $schema is correct as new Yiisoft\Yii\Cycle\Sc...Merger()->merge($parts) targeting Yiisoft\Yii\Cycle\Schema...t\SchemaMerger::merge() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
29
30 12
        if ($schema !== null || $nextProvider === null) {
31 10
            return $schema;
32
        }
33 3
        return  $nextProvider->read();
34
    }
35
}
36