| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Json implements FileWriterInterface |
||
| 6 | { |
||
| 7 | protected string $filePath; |
||
| 8 | |||
| 9 | /** @var resource File pointer */ |
||
| 10 | protected $file = null; |
||
| 11 | |||
| 12 | public function __construct(string $filePath) |
||
| 13 | { |
||
| 14 | $this->filePath = $filePath; |
||
| 15 | } |
||
| 16 | |||
| 17 | protected function init() |
||
| 18 | { |
||
| 19 | if (is_null($this->file)) { |
||
|
|
|||
| 20 | $this->file = fopen($this->filePath, 'w'); |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | public function write($rowData) |
||
| 25 | { |
||
| 26 | $this->init(); |
||
| 27 | fputs($this->file, json_encode($rowData) . "\n"); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getResource() |
||
| 33 | } |
||
| 34 | } |
||
| 35 |