Passed
Push — master ( eb9c6b...2046e5 )
by Fabrice
02:42
created

FileLoaderAbstract::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of YaEtl.
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Loaders\File;
11
12
use fab2s\NodalFlow\NodalFlowException;
13
use fab2s\NodalFlow\YaEtlException;
14
use fab2s\YaEtl\Loaders\LoaderAbstract;
15
use fab2s\YaEtl\Traits\FileHandlerTrait;
16
17
/**
18
 * Class FileLoaderAbstract
19
 */
20
abstract class FileLoaderAbstract extends LoaderAbstract
21
{
22
    use FileHandlerTrait;
23
24
    /**
25
     * @param mixed|resource|string $input
26
     *
27
     * @throws YaEtlException
28
     * @throws NodalFlowException
29
     */
30
    public function __construct($input)
31
    {
32
        $this->initHandle($input, 'wb');
33
34
        $metaData = stream_get_meta_data($this->handle);
35
        if (!is_writable($metaData['uri'])) {
36
            throw new YaEtlException('CsvLoader : destination cannot be opened in write mode');
37
        }
38
39
        parent::__construct();
40
    }
41
}
42