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

MergeSchemaProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 16 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