Completed
Push — V6 ( b362d7...e9a4a9 )
by Georges
02:18
created

CustomMemcachedCacheClass   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1
1
<?php
2
3
/**
4
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
5
 * @author Georges.L (Geolim4)  <[email protected]>
6
 */
7
8
use phpFastCache\Core\Item\ExtendedCacheItemInterface;
9
use phpFastCache\Helper\TestHelper;
10
use phpFastCache\Proxy\phpFastCacheAbstractProxy;
11
12
13
chdir(__DIR__);
14
require_once __DIR__ . '/../vendor/autoload.php';
15
$testHelper = new TestHelper('phpFastCacheAbstractProxy class');
16
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
17
18
/**
19
 * Dynamic driver-based example
20
 * Class myCustomCacheClass
21
 * @package MyCustom\Project
22
 */
23
class CustomMemcachedCacheClass extends phpFastCacheAbstractProxy
24
{
25
    public function __construct($driver = '', array $config = [])
26
    {
27
        global $defaultDriver;
28
        $driver = $defaultDriver;
29
        parent::__construct($driver, $config);
30
        /**
31
         * That's all !! Your cache class is ready to use
32
         */
33
    }
34
}
35
36
37
/**
38
 * Testing memcached as it is declared in .travis.yml
39
 */
40
$driverInstance = new CustomMemcachedCacheClass();
41
42
if (!is_object($driverInstance->getItem('test'))) {
43
    $testHelper->printFailText('$driverInstance->getItem() returned an invalid var type:' . gettype($driverInstance));
44
}else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){
45
    $testHelper->printFailText('$driverInstance->getItem() returned an invalid class that does not implements ExtendedCacheItemInterface: ' . get_class($driverInstance));
46
}else{
47
    $testHelper->printPassText('$driverInstance->getItem() returned a valid class that implements ExtendedCacheItemInterface: ' . get_class($driverInstance));
48
}
49
50
$testHelper->terminateTest();