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

FileDumperTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setFilename() 0 4 1
A __construct() 0 3 1
A clearHandle() 0 5 2
A __destruct() 0 3 1
A getFilename() 0 3 1
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
}