AbstractFile::close()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Maketok\DataMigration\Input;
4
5
abstract class AbstractFile implements InputResourceInterface
6
{
7
    /**
8
     * @var \SplFileObject
9
     */
10
    protected $descriptor;
11
12
    /**
13
     * @param string $fileName
14
     * @param string $mode
15
     */
16 12
    public function __construct($fileName, $mode = 'r')
17
    {
18 12
        $this->descriptor = new \SplFileObject($fileName, $mode);
19 12
    }
20
21
    /**
22
     * close file resource
23
     */
24 12
    public function close()
25
    {
26 12
        if (isset($this->descriptor)) {
27 12
            $this->descriptor = null;
28 12
        }
29 12
    }
30
31
    /**
32
     * clean internal pointer
33
     */
34 12
    public function __destruct()
35
    {
36 12
        $this->close();
37 12
    }
38
}
39