SchemaProviderPipeline::read()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Provider\Support;
6
7
use Cycle\Schema\Provider\Exception\SchemaProviderException;
8
use Cycle\Schema\Provider\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 SchemaProviderException(self::class . ' is not configured.');
20
        }
21 14
        if ($this->providers->count() === 0) {
22 4
            return $nextProvider?->read();
23
        }
24
25 11
        return $this->providers[0]->read($nextProvider);
26
    }
27
}
28