Passed
Branch feature/first-release (43e0cc)
by Andrea Marco
10:48
created

CustomSource::calculateSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Cerbero\JsonParser\Sources;
4
5
use Traversable;
6
7
/**
8
 * The custom source.
9
 *
10
 * @property-read Source $source
11
 */
12
class CustomSource extends Source
13
{
14
    /**
15
     * Retrieve the JSON fragments
16
     *
17
     * @return Traversable<int, string>
18
     */
19 2
    public function getIterator(): Traversable
20
    {
21 2
        yield from $this->source;
22
    }
23
24
    /**
25
     * Determine whether the JSON source can be handled
26
     *
27
     * @return bool
28
     */
29 130
    public function matches(): bool
30
    {
31 130
        return $this->source instanceof Source;
32
    }
33
34
    /**
35
     * Retrieve the calculated size of the JSON source
36
     *
37
     * @return int|null
38
     */
39
    protected function calculateSize(): ?int
40
    {
41
        return $this->source->size();
42
    }
43
}
44