CustomSource::calculateSize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

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 2
cts 2
cp 1
crap 1
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 14
    public function getIterator(): Traversable
20
    {
21 14
        yield from $this->source;
22
    }
23
24
    /**
25
     * Determine whether the JSON source can be handled
26
     *
27
     * @return bool
28
     */
29 361
    public function matches(): bool
30
    {
31 361
        return $this->source instanceof Source;
32
    }
33
34
    /**
35
     * Retrieve the calculated size of the JSON source
36
     *
37
     * @return int|null
38
     */
39 2
    protected function calculateSize(): ?int
40
    {
41 2
        return $this->source->size();
42
    }
43
}
44