Passed
Push — master ( 896e22...61bd56 )
by Dāvis
03:36
created

FileDumperTrait::__destruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Sitemap\Dumper;
4
5
trait FileDumperTrait
6
{
7
    protected $filename = null;
8
    protected $handle = null;
9
10
    /**
11
     * Constructor.
12
     *
13
     * @param string $filename The filename. Must be acessible in write mode.
14
     */
15
    public function __construct($filename)
16
    {
17
        $this->filename = $filename;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getFilename()
24
    {
25
        return $this->filename;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function setFilename($filename)
32
    {
33
        $this->clearHandle();
34
        $this->filename = $filename;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function clearHandle()
41
    {
42
        if ($this->handle !== null) {
43
            fclose($this->handle);
44
            $this->handle = null;
45
        }
46
    }
47
48
    public function __destruct()
49
    {
50
        $this->clearHandle();
51
    }
52
}