woocommerce-pos
/
vendor_prefixed
/
phpfastcache
/
phpfastcache
/
lib
/
Phpfastcache
/
Proxy
/
PhpfastcacheAbstractProxy.php
PhpfastcacheAbstractProxy.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.9.14, at vendor_prefixed/phpfastcache/phpfastcache/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxy.php
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * This file is part of phpFastCache. |
| 6 | * |
| 7 | * @license MIT License (MIT) |
| 8 | * |
| 9 | * For full copyright and license information, please see the docs/CREDITS.txt file. |
| 10 | * |
| 11 | * @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> https://www.phpfastcache.com |
| 12 | * @author Georges.L (Geolim4) <contact@geolim4.com> |
| 13 | * |
| 14 | */ |
| 15 | declare (strict_types=1); |
| 16 | namespace WCPOS\Vendor\Phpfastcache\Proxy; |
| 17 | |
| 18 | use BadMethodCallException; |
| 19 | use WCPOS\Vendor\Phpfastcache\CacheManager; |
| 20 | use WCPOS\Vendor\Phpfastcache\Core\Item\ExtendedCacheItemInterface; |
| 21 | use WCPOS\Vendor\Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 22 | use WCPOS\Vendor\Phpfastcache\Entities\DriverStatistic; |
| 23 | use WCPOS\Vendor\Psr\Cache\CacheItemInterface; |
| 24 | /** |
| 25 | * Class phpFastCache |
| 26 | * |
| 27 | * Handle methods using annotations for IDE |
| 28 | * because they're handled by __call() |
| 29 | * Check out ExtendedCacheItemInterface to see all |
| 30 | * the drivers methods magically implemented |
| 31 | * |
| 32 | * @method ExtendedCacheItemInterface getItem($key) Retrieve an item and returns an empty item if not found |
| 33 | * @method ExtendedCacheItemInterface[] getItems(array $keys) Retrieve an item and returns an empty item if not found |
| 34 | * @method bool hasItem() hasItem($key) Tests if an item exists |
| 35 | * @method bool deleteItem(string $key) Delete an item |
| 36 | * @method bool deleteItems(array $keys) Delete some items |
| 37 | * @method bool save(CacheItemInterface $item) Save an item |
| 38 | * @method bool saveDeferred(CacheItemInterface $item) Sets a cache item to be persisted later |
| 39 | * @method bool commit() Persists any deferred cache items |
| 40 | * @method bool clear() Allow you to completely empty the cache and restart from the beginning |
| 41 | * @method DriverStatistic stats() Returns a DriverStatistic object |
| 42 | * @method ExtendedCacheItemInterface getItemsByTag($tagName) Return items by a tag |
| 43 | * @method ExtendedCacheItemInterface[] getItemsByTags(array $tagNames) Return items by some tags |
| 44 | * @method bool deleteItemsByTag($tagName) Delete items by a tag |
| 45 | * @method bool deleteItemsByTags(array $tagNames) // Delete items by some tags |
| 46 | * @method void incrementItemsByTag($tagName, $step = 1) // Increment items by a tag |
| 47 | * @method void incrementItemsByTags(array $tagNames, $step = 1) // Increment items by some tags |
| 48 | * @method void decrementItemsByTag($tagName, $step = 1) // Decrement items by a tag |
| 49 | * @method void decrementItemsByTags(array $tagNames, $step = 1) // Decrement items by some tags |
| 50 | * @method void appendItemsByTag($tagName, $data) // Append items by a tag |
| 51 | * @method void appendItemsByTags(array $tagNames, $data) // Append items by a tags |
| 52 | * @method void prependItemsByTag($tagName, $data) // Prepend items by a tag |
| 53 | * @method void prependItemsByTags(array $tagNames, $data) // Prepend items by a tags |
| 54 | */ |
| 55 | abstract class PhpfastcacheAbstractProxy |
| 56 | { |
| 57 | /** |
| 58 | * @var ExtendedCacheItemPoolInterface |
| 59 | */ |
| 60 | protected $instance; |
| 61 | /** |
| 62 | * PhpfastcacheAbstractProxy constructor. |
| 63 | * @param string $driver |
| 64 | * @param null $config |
| 65 | * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverCheckException |
| 66 | * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverException |
| 67 | * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException |
| 68 | * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException |
| 69 | * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException |
| 70 | * @throws \Phpfastcache\Exceptions\PhpfastcacheLogicException |
| 71 | * @throws \ReflectionException |
| 72 | */ |
| 73 | public function __construct(string $driver, $config = null) |
| 74 | { |
| 75 | $this->instance = CacheManager::getInstance($driver, $config); |
| 76 | } |
| 77 | /** |
| 78 | * @param string $name |
| 79 | * @param array $args |
| 80 | * @return mixed |
| 81 | * @throws BadMethodCallException |
| 82 | */ |
| 83 | public function __call(string $name, array $args) |
| 84 | { |
| 85 | if (\method_exists($this->instance, $name)) { |
| 86 | return $this->instance->{$name}(...$args); |
| 87 | } |
| 88 | throw new BadMethodCallException(\sprintf('Method %s does not exists', $name)); |
| 89 | } |
| 90 | } |
| 91 |