| Conditions | 5 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function __construct($input) |
||
| 31 | { |
||
| 32 | if (is_resource($input)) { |
||
| 33 | $this->handle = $input; |
||
| 34 | } elseif (is_file($input)) { |
||
| 35 | $this->handle = fopen($input, 'wb'); |
||
| 36 | if (!$this->handle) { |
||
| 37 | throw new YaEtlException('CsvLoader : destination cannot be opened in write mode'); |
||
| 38 | } |
||
| 39 | } else { |
||
| 40 | throw new YaEtlException('Input is either not a resource or not a file'); |
||
| 41 | } |
||
| 42 | |||
| 43 | $metaData = stream_get_meta_data($this->handle); |
||
| 44 | if (!is_writable($metaData['uri'])) { |
||
| 45 | throw new YaEtlException('CsvLoader : destination cannot be opened in write mode'); |
||
| 46 | } |
||
| 47 | |||
| 48 | parent::__construct(); |
||
| 49 | } |
||
| 51 |