Completed
Push — master ( f64d9c...5ef3c4 )
by Jean-Christophe
01:47
created

CacheFile   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 18
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 84
rs 10
1
<?php
2
3
namespace micro\controllers\admin\popo;
4
5
use micro\cache\CacheManager;
6
7
class CacheFile {
8
	private $type;
9
	private $name;
10
	private $timestamp;
11
	private $size;
12
	private $file;
13
14
	public function __construct($type="",$name="",$timestamp=0,$size=0,$file=""){
15
		$this->type=$type;
16
		$this->name=$name;
17
		$this->timestamp=$timestamp;
18
		$this->size=$size;
19
		$this->file=$file;
20
	}
21
22
	public static function init($folder,$type){
23
		$files=CacheManager::glob_recursive($folder . DS . '*');
24
		$result=[];
25
		foreach ($files as $file){
26
			if (is_file($file)) {
27
				$result[]=new CacheFile($type,\basename($file),\filectime($file),\filesize($file),$file);
28
			}
29
		}
30
		if(\sizeof($result)==0)
31
			$result[]=new CacheFile($type,"","","","");
32
		return $result;
33
	}
34
35
	public static function delete($folder){
36
		$files=CacheManager::glob_recursive($folder . DS . '*');
37
		foreach ($files as $file){
38
			if (is_file($file)) {
39
				\unlink($file);
40
			}
41
		}
42
	}
43
44
	public function getName() {
45
		return $this->name;
46
	}
47
48
	public function setName($name) {
49
		$this->name=$name;
50
		return $this;
51
	}
52
53
	public function getTimestamp() {
54
		return $this->timestamp;
55
	}
56
57
	public function setTimestamp($timestamp) {
58
		$this->timestamp=$timestamp;
59
		return $this;
60
	}
61
62
	public function getSize() {
63
		return $this->size;
64
	}
65
66
	public function setSize($size) {
67
		$this->size=$size;
68
		return $this;
69
	}
70
71
	public function getType() {
72
		return $this->type;
73
	}
74
75
	public function setType($type) {
76
		$this->type=$type;
77
		return $this;
78
	}
79
80
	public function getFile() {
81
		return $this->file;
82
	}
83
84
	public function setFile($file) {
85
		$this->file=$file;
86
		return $this;
87
	}
88
89
90
}
91