Passed
Pull Request — master (#86)
by Aleksei
04:24 queued 41s
created

SchemaProviderPipeline::createPipeline()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 15
ccs 12
cts 12
cp 1
rs 9.9
cc 4
nc 3
nop 2
crap 4
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
 * When the schema is read, it queues the specified schema providers using the {@see DeferredSchemaProviderDecorator}.
13
 */
14
final class SchemaProviderPipeline extends BaseProviderCollector
15
{
16 15
    public function read(?SchemaProviderInterface $nextProvider = null): ?array
17
    {
18 15
        if ($this->providers === null) {
19 1
            throw new RuntimeException(self::class . ' is not configured.');
20
        }
21 14
        if ($this->providers->count() === 0) {
22 4
            return $nextProvider === null ? null : $nextProvider->read();
23
        }
24 11
        return $this->providers[0]->read($nextProvider);
25
    }
26
}
27