Completed
Push — master ( cd46ad...a80418 )
by
unknown
37:43
created

DummyStorage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 67
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A set() 0 4 1
A getOrSet() 0 5 1
A delete() 0 4 1
A buildKey() 0 4 1
1
<?php
2
3
namespace yiicod\geo\storages;
4
5
6
/**
7
 * Class DummyStorage
8
 * Dummy storage
9
 *
10
 * @package yiicod\geo\storages
11
 *
12
 * @author Dmitry Turchanin
13
 */
14
class DummyStorage implements StorageInterface
15
{
16
17
    /**
18
     * Gets data for $key from storage
19
     *
20
     * @param $key
21
     *
22
     * @return mixed
23
     */
24
    public function get($key)
25
    {
26
        return false;
27
    }
28
29
    /**
30
     * Stores data for $key into storage
31
     *
32
     * @param $key
33
     * @param $value
34
     * @param int $duration
35
     */
36
    public function set($key, $value, $duration = 0): void
37
    {
38
        // nothing to do
39
    }
40
41
    /**
42
     * Method combines both [[set()]] and [[get()]] methods to retrieve value identified by a $key,
43
     * or to store the result of $callable execution if there is no cache available for the $ip.
44
     *
45
     * @param $key
46
     * @param $callable
47
     * @param int $duration
48
     *
49
     * @return mixed
50
     */
51
    public function getOrSet($key, $callable, $duration = 0)
52
    {
53
        $value = call_user_func($callable, $this);
54
        return $value;
55
    }
56
57
    /**
58
     * Deletes record from storage for $key
59
     *
60
     * @param $key
61
     *
62
     * @return mixed
63
     */
64
    public function delete($key): void
65
    {
66
        // nothing to do
67
    }
68
69
    /**
70
     * Builds a normalized storage key from a given IP.
71
     *
72
     * @param mixed $key the key to be normalized
73
     *
74
     * @return string the generated cache key
75
     */
76
    public function buildKey($key): string
77
    {
78
        return '';
79
    }
80
}