BaseCache::proxy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 2
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
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 Jitamin\Foundation\Cache;
13
14
/**
15
 * Base Class for Cache Drivers.
16
 */
17
abstract class BaseCache implements CacheInterface
18
{
19
    /**
20
     * Proxy cache.
21
     *
22
     * Note: Arguments must be scalar types
23
     *
24
     * @param string $class  Class instance
25
     * @param string $method Container method
26
     *
27
     * @return mixed
28
     */
29
    public function proxy($class, $method)
30
    {
31
        $args = func_get_args();
32
        array_shift($args);
33
34
        $key = 'proxy:'.get_class($class).':'.implode(':', $args);
35
        $result = $this->get($key);
36
37
        if ($result === null) {
38
            $result = call_user_func_array([$class, $method], array_splice($args, 1));
39
            $this->set($key, $result);
0 ignored issues
show
Bug introduced by
The call to set() misses a required argument $minutes.

This check looks for function calls that miss required arguments.

Loading history...
40
        }
41
42
        return $result;
43
    }
44
}
45