ArrayCache   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A set() 0 5 1
A has() 0 4 1
1
<?php
2
3
namespace SitePoint\Rauth;
4
5
final class ArrayCache implements Cache
6
{
7
    private $data = [];
8
9 75
    public function __construct(array $data = [])
10
    {
11 75
        $this->data = $data;
12 75
    }
13
14 74
    public function get(string $key)
15
    {
16 74
        return $this->data[$key] ?? null;
17
    }
18
19 74
    public function set(string $key, $value) : Cache
20
    {
21 74
        $this->data[$key] = $value;
22 74
        return $this;
23
    }
24
25 74
    public function has(string $key) : bool
26
    {
27 74
        return isset($this->data[$key]);
28
    }
29
}
30