json_writer::set_file()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * © 2018 - Phoponent
5
 * Author: Nicolas Choquet
6
 * Email: [email protected]
7
 * LICENSE GPL ( GNU General Public License )
8
 */
9
10
namespace phoponent\framework\service;
11
12
use phoponent\framework\traits\service;
13
14
class json_writer {
15
	use service;
16
	protected $file = '';
17
	protected $datas = [];
18
19
	public function set_file($file) {
20
		$this->file = "$file.json";
21
		return $this;
22
	}
23
24
	public function set_datas($name, $value) {
25
		$this->datas[$name] = $value;
26
	}
27
28
	public function write() {
29
		file_put_contents($this->file, json_encode($this->datas));
30
	}
31
}