Test Failed
Push — master ( a0576a...ebf6f0 )
by Juuso
09:48 queued 11s
created

DataLoaderOptions   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 50
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace leinonen\DataLoader;
4
5
final class DataLoaderOptions
6
{
7
    private bool $shouldBatch;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
8
9
    private ?int $maxBatchSize;
10
11
    private bool $shouldCache;
12
13
    public function __construct(
14
        ?int $maxBatchSize = null,
15
        bool $shouldBatch = true,
16
        bool $shouldCache = true
17
    ) {
18
        $this->validateMaxBatchSizeOption($maxBatchSize);
19
        $this->shouldBatch = $shouldBatch;
20
        $this->maxBatchSize = $maxBatchSize;
21
        $this->shouldCache = $shouldCache;
22
    }
23
24 34
    public function shouldBatch(): bool
25
    {
26
        return $this->shouldBatch;
27
    }
28
29 34
    public function getMaxBatchSize(): ?int
30 33
    {
31 33
        return $this->maxBatchSize;
32 33
    }
33 33
34
    public function shouldCache(): bool
35 30
    {
36
        return $this->shouldCache;
37 30
    }
38
39
    private function validateMaxBatchSizeOption(?int $maxBatchSize)
40 29
    {
41
        if ($maxBatchSize !== null && $maxBatchSize < 0) {
42 29
            throw new \InvalidArgumentException('Expected argument $maxBatchSize to be null or a positive integer');
43
        }
44
    }
45
}
46