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

File::close()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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