Completed
Push — master ( 534878...ea6b08 )
by Tom
02:29
created

FileCache::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/* @description     Transformation Style Sheets - Revolutionising PHP templating    *
3
 * @author          Tom Butler [email protected]                                             *
4
 * @copyright       2015 Tom Butler <[email protected]> | https://r.je/                      *
5
 * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License *
6
 * @version         0.9                                                             */
7
namespace Transphporm;
8
class FileCache {
9
	private $cache;
10
11
	public function __construct(\ArrayAccess $cache) {
12
		$this->cache = $cache;
13
	}
14
15
	public function write($key, $content) {		
16
		$this->cache[$key] = ['content' => $content, 'timestamp' => time()];		
17
		return $content;
18
	}
19
20
	public function load($key, $modified = 0) {
21
		if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) {
22
			return $this->cache[$key]['content'];
23
		}
24
		else return false;
25
	}
26
}