json_writer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 16
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set_datas() 0 2 1
A set_file() 0 3 1
A write() 0 2 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
}