EasyCache::cache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Sulao\EasyCache;
4
5
/**
6
 * Trait EasyCache
7
 *
8
 * @package Sulao\EasyCache
9
 */
10
trait EasyCache
11
{
12
    /**
13
     * Call this method to cache the result of the method in next call.
14
     * $class->cache()->get(1) will cache the result of $class->get(1);
15
     *
16
     * @param int|null    $ttl    if null, will use the ttl in config file,
17
     *                            if not specified in config file, then 3600
18
     * @param string|null $key    if null, will serialize the instance class
19
     *                            name, method name and parameters as key. Has
20
     *                            to specify key if parameters have closure
21
     * @param string|null $store  laravel cache store
22
     *
23
     * @return CachePlug|static
24
     */
25 2
    public function cache($ttl = null, $key = null, $store = null)
26
    {
27 2
        return new CachePlug($this, $ttl, $key, $store);
28
    }
29
}
30