Completed
Push — master ( 980c15...74d9cb )
by Jean-Christophe
01:25
created

CacheFile::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 . '*');
0 ignored issues
show
Bug introduced by
The method glob_recursive() cannot be called from this context as it is declared private in class micro\cache\CacheManager.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
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 . '*');
0 ignored issues
show
Bug introduced by
The method glob_recursive() cannot be called from this context as it is declared private in class micro\cache\CacheManager.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
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