Conditions | 5 |
Paths | 8 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function __construct($path, $mode = 'r+', $isNeedBOM = false, $headers = array()) |
||
12 | { |
||
13 | $isNewFile = false; |
||
14 | |||
15 | if (! file_exists($path)) { |
||
16 | touch($path); |
||
17 | $isNewFile = true; |
||
18 | } |
||
19 | $this->handle = new \SplFileObject($path, $mode); |
||
20 | $this->handle->setFlags(\SplFileObject::DROP_NEW_LINE); |
||
21 | |||
22 | if ($isNeedBOM) { |
||
23 | $this->handle->fwrite("\xEF\xBB\xBF"); |
||
24 | } |
||
25 | |||
26 | if($isNewFile && isset($headers)) { |
||
27 | $headerLine = join(',', $headers) . PHP_EOL; |
||
28 | $this->handle->fwrite($headerLine, strlen($headerLine)); |
||
29 | } |
||
30 | } |
||
31 | |||
47 |