Security update for permissions_by_term
[yaffs-website] / vendor / behat / gherkin / src / Behat / Gherkin / Cache / MemoryCache.php
1 <?php
2
3 /*
4 * This file is part of the Behat Gherkin.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 namespace Behat\Gherkin\Cache;
12
13 use Behat\Gherkin\Node\FeatureNode;
14
15 /**
16  * Memory cache.
17  * Caches feature into a memory.
18  *
19  * @author Konstantin Kudryashov <ever.zet@gmail.com>
20  */
21 class MemoryCache implements CacheInterface
22 {
23     private $features = array();
24     private $timestamps = array();
25
26     /**
27      * Checks that cache for feature exists and is fresh.
28      *
29      * @param string  $path      Feature path
30      * @param integer $timestamp The last time feature was updated
31      *
32      * @return Boolean
33      */
34     public function isFresh($path, $timestamp)
35     {
36         if (!isset($this->features[$path])) {
37             return false;
38         }
39
40         return $this->timestamps[$path] > $timestamp;
41     }
42
43     /**
44      * Reads feature cache from path.
45      *
46      * @param string $path Feature path
47      *
48      * @return FeatureNode
49      */
50     public function read($path)
51     {
52         return $this->features[$path];
53     }
54
55     /**
56      * Caches feature node.
57      *
58      * @param string      $path    Feature path
59      * @param FeatureNode $feature Feature instance
60      */
61     public function write($path, FeatureNode $feature)
62     {
63         $this->features[$path]   = $feature;
64         $this->timestamps[$path] = time();
65     }
66 }