FileDumper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A openFile() 0 6 2
A dump() 0 7 2
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