Passed
Push — master ( f8e1da...c49986 )
by Edson
01:13
created

File   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

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