Passed
Push — master ( ef93dc...4f7931 )
by
unknown
13:58
created

CacheStorage::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of ibrand/laravel-sms.
5
 *
6
 * (c) iBrand <https://www.ibrand.cc>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace iBrand\Sms\Storage;
13
14
use Cache;
15
16
/**
17
 * Class CacheStorage.
18
 */
19
class CacheStorage implements StorageInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    protected static $lifetime = 120;
25
26
    /**
27
     * @param $key
28
     * @param $value
29
     */
30 23
    public function set($key, $value)
31
    {
32 23
        Cache::put($key, $value, self::$lifetime);
33 23
    }
34
35
    /**
36
     * @param $key
37
     * @param $default
38
     *
39
     * @return mixed
40
     */
41 21
    public function get($key, $default)
42
    {
43 21
        return Cache::get($key, $default);
44
    }
45
46
    /**
47
     * @param $key
48
     */
49 3
    public function forget($key)
50
    {
51 3
        if (Cache::has($key)) {
52 3
            Cache::forget($key);
53
        }
54 3
    }
55
}
56