Passed
Push — etls ( 3c161b )
by Fabrice
11:34
created

EtlStreamAbstract::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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\Etl\Streams;
11
12
use fab2s\NodalFlow\NodalFlowException;
13
use fab2s\YaEtl\Etl\EtlAbstract;
14
use fab2s\YaEtl\Etl\Streams\Traits\SlashPath;
15
use fab2s\YaEtl\YaEtlException;
16
use ReflectionException;
17
18
abstract class EtlStreamAbstract extends EtlAbstract
19
{
20
    use SlashPath;
21
22
    /**
23
     * @throws NodalFlowException
24
     * @throws YaEtlException|ReflectionException
25
     *
26
     * @return $this
27
     */
28
    public function run(): EtlAbstract
29
    {
30
        parent::run();
31
32
        return $this->releaseStreams();
33
    }
34
35
    protected function releaseStreams(): EtlStreamAbstract
36
    {
37
        foreach (['sourceStream', 'destinationStream'] as $stream) {
38
            if (!empty($this->$stream)) {
39
                fclose($this->$stream);
40
                $this->$stream = null;
41
            }
42
        }
43
44
        return $this;
45
    }
46
}
47