FakeDumpReader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A rewind() 0 3 1
A nextJsonLine() 0 11 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Wikibase\JsonDumpReader\Reader;
6
7
use Wikibase\JsonDumpReader\DumpReader;
8
9
/**
10
 * Package public
11
 * @since 1.0.0
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class FakeDumpReader implements DumpReader {
17
18
	/**
19
	 * @var string[]
20
	 */
21
	private $lines;
22
23
	/**
24
	 * @param string $lines
25
	 */
26 5
	public function __construct( $lines ) {
27 5
		$this->lines = $lines;
0 ignored issues
show
Documentation Bug introduced by
It seems like $lines of type string is incompatible with the declared type array<integer,string> of property $lines.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28 5
		$this->rewind();
29 5
	}
30
31 5
	public function rewind(): void {
32 5
		reset( $this->lines );
33 5
	}
34
35
	/**
36
	 * @return string|null
37
	 */
38 5
	public function nextJsonLine(): ?string {
39 5
		$current = current( $this->lines );
40
41 5
		if ( $current === false ) {
42 2
			return null;
43
		}
44
		else {
45 5
			next( $this->lines );
46 5
			return $current;
47
		}
48
	}
49
50
}
51