Completed
Push — master ( 8d3e79...9daf84 )
by Edson
04:12
created

File   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 4 1
A close() 0 3 1
A read() 0 9 1
A create() 0 6 1
1
<?php
2
3
namespace Bonfim\Tpl;
4
5
class File
6
{
7
    private $name;
8
    private $file;
9
10 2
    public function create(string $name)
11
    {
12 2
        $this->name = $name;
13 2
        $this->file = fopen($name, 'w+');
14
15 2
        return $this->file;
16
    }
17
18 2
    public function write(string $content): void
19
    {
20 2
        fwrite($this->file, $content);
21 2
        fseek($this->file, 0);
22 2
    }
23
24 2
    public function read(array $data): string
25
    {
26 2
        extract($data);
27
28 2
        ob_start();
29
30 2
        include $this->name;
31
32 2
        return ob_get_clean();
33
    }
34
35 2
    public function close(): void
36
    {
37 2
        fclose($this->file);
38 2
    }
39
}
40