File::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
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
}