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

File::close()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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