FileDumper::dump()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Sitemap\Dumper;
4
5
class FileDumper implements DumperFileInterface
6
{
7
    use FileDumperTrait;
8
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function dump($string)
13
    {
14
        if ($this->handle === null) {
15
            $this->openFile();
16
        }
17
18
        fwrite($this->handle, $string);
19
    }
20
21
    protected function openFile()
22
    {
23
        $this->handle = fopen($this->filename, 'w+b');
24
25
        if ($this->handle === false) {
26
            throw new \RuntimeException(sprintf('Impossible to open the file %s in write mode', $this->filename));
27
        }
28
    }
29
}
30