Completed
Push — v5 ( 48ce1b...2f506e )
by Georges
03:06
created

phpFastCacheAbstractProxy::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 *
4
 * This file is part of phpFastCache.
5
 *
6
 * @license MIT License (MIT)
7
 *
8
 * For full copyright and license information, please see the docs/CREDITS.txt file.
9
 *
10
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 *
13
 */
14
namespace phpFastCache\Proxy;
15
16
use phpFastCache\Cache\ExtendedCacheItemInterface;
17
use phpFastCache\CacheManager;
18
use phpFastCache\Entities\driverStatistic;
19
use Psr\Cache\CacheItemInterface;
20
21
/**
22
 * Class phpFastCache
23
 *
24
 * Handle methods using annotations for IDE
25
 * because they're handled by __call()
26
 * Check out DriverInterface to see all
27
 * the drivers methods magically implemented
28
 *
29
 * @method ExtendedCacheItemInterface getItem($key) Retrieve an item and returns an empty item if not found
30
 * @method ExtendedCacheItemInterface[] getItems(array $keys) Retrieve an item and returns an empty item if not found
31
 * @method bool hasItem() hasItem($key) Tests if an item exists
32
 * @method bool deleteItem(string $key) Delete an item
33
 * @method bool deleteItems(array $keys) Delete some items
34
 * @method bool save(CacheItemInterface $item) Save an item
35
 * @method bool saveDeferred(CacheItemInterface $item) Sets a cache item to be persisted later
36
 * @method bool commit() Persists any deferred cache items
37
 * @method bool clear() Allow you to completely empty the cache and restart from the beginning
38
 * @method driverStatistic stats() Allow you to completely empty the cache and restart from the beginning
39
 * @method ExtendedCacheItemInterface getItemsByTag($tagName) Return items by a tag
40
 * @method ExtendedCacheItemInterface[] getItemsByTags(array $tagNames) Return items by some tags
41
 * @method bool deleteItemsByTag($tagName) Delete items by a tag
42
 * @method bool deleteItemsByTags(array $tagNames) // Delete items by some tags
43
 * @method void incrementItemsByTag($tagName, $step = 1) // Increment items by a tag
44
 * @method void incrementItemsByTags(array $tagNames, $step = 1) // Increment items by some tags
45
 * @method void decrementItemsByTag($tagName, $step = 1) // Decrement items by a tag
46
 * @method void decrementItemsByTags(array $tagNames, $step = 1) // Decrement items by some tags
47
 * @method void appendItemsByTag($tagName, $data) // Append items by a tag
48
 * @method void appendItemsByTags(array $tagNames, $data) // Append items by a tags
49
 * @method void prependItemsByTag($tagName, $data) // Prepend items by a tag
50
 * @method void prependItemsByTags(array $tagNames, $data) // Prepend items by a tags
51
 */
52
abstract class phpFastCacheAbstractProxy
53
{
54
    /**
55
     * @var \phpFastCache\Cache\ExtendedCacheItemPoolInterface
56
     */
57
    protected $instance;
58
59
    /**
60
     * phpFastCache constructor.
61
     * @param string $driver
62
     * @param array $config
63
     */
64
    public function __construct($driver  = '', array $config = [])
65
    {
66
        $this->instance = CacheManager::getInstance($driver, $config);
67
    }
68
69
    /**
70
     * @param $name
71
     * @param $args
72
     * @return mixed
73
     */
74
    public function __call($name, $args)
75
    {
76
        return call_user_func_array(array($this->instance, $name), $args);
77
    }
78
}