ReflectionCacheArray::fetch()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 4
nop 1
1
<?php
2
3
namespace Atreyu;
4
5
class ReflectionCacheArray implements ReflectionCache
6
{
7
    private $cache = [];
8
9
    public function fetch($key)
10
    {
11
        // The additional isset() check here improves performance but we also
12
        // need array_key_exists() because some cached values === NULL.
13
        return (isset($this->cache[$key]) || array_key_exists($key, $this->cache))
14
            ? $this->cache[$key]
15
            : false;
16
    }
17
18
    public function store($key, $data)
19
    {
20
        $this->cache[$key] = $data;
21
    }
22
}
23