1 | <?php |
||
14 | class Bz2DumpReader implements DumpReader { |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $dumpFile; |
||
20 | |||
21 | /** |
||
22 | * @var resource|null |
||
23 | */ |
||
24 | private $handle = null; |
||
25 | |||
26 | private $lines = [ '' ]; |
||
27 | |||
28 | /** |
||
29 | * @param string $dumpFilePath |
||
30 | */ |
||
31 | 4 | public function __construct( $dumpFilePath ) { |
|
34 | |||
35 | 4 | public function __destruct() { |
|
38 | |||
39 | 4 | private function closeReader() { |
|
40 | 4 | if ( is_resource( $this->handle ) ) { |
|
41 | 3 | bzclose( $this->handle ); |
|
42 | 3 | $this->handle = null; |
|
43 | } |
||
44 | 4 | } |
|
45 | |||
46 | 1 | public function rewind() { |
|
51 | |||
52 | 4 | private function initReader() { |
|
53 | 4 | if ( $this->handle === null ) { |
|
54 | 4 | $this->handle = @bzopen( $this->dumpFile, 'r' ); |
|
55 | |||
56 | 4 | if ( $this->handle === false ) { |
|
57 | 1 | throw new DumpReadingException( 'Could not open file: ' . $this->dumpFile ); |
|
58 | } |
||
59 | } |
||
60 | 3 | } |
|
61 | |||
62 | /** |
||
63 | * @return string|null |
||
64 | * @throws DumpReadingException |
||
65 | */ |
||
66 | 4 | public function nextJsonLine() { |
|
80 | |||
81 | 3 | private function nextLine() { |
|
82 | 3 | while ( !feof( $this->handle ) && count( $this->lines ) === 1 ) { |
|
99 | |||
100 | } |
||
101 |