File   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 28
wmc 3
lcom 0
cbo 0
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 7 1
A get() 0 9 2
1
<?php
2
namespace Skansing\Escapology\Cacher;
3
4
use \Skansing\Escapology\Cacher;
5
6
class File implements Cacher {
7
8
  /**
9
   * @param string $key  File to save the cached data 
10
   * @param value $value Cached data
11
   */
12 3
  public function set($key, $value)
13
  {
14 3
    file_put_contents(
15 3
      $key,
16 3
      '<?php return ' . var_export($value, true) . ';'
17 3
    );
18 3
  }
19
20
  /**
21
   * @param  string $key File to get cached data 
22
   * @return Mixed False if not cache is found
23
   */
24 2
  public function get($key)
25
  {
26 2
    if(file_exists($key) === false) {
27
28 1
      return false;
29
    }
30
31 1
    return require $key;
32
  }
33
}