CustomSource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 3 1
A getIterator() 0 3 1
A calculateSize() 0 3 1
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