Completed
Pull Request — final (#419)
by Georges
04:26 queued 02:13
created

CustomMemcachedCacheClass::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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\Cache\ExtendedCacheItemInterface;
9
use phpFastCache\Proxy\phpFastCacheAbstractProxy;
10
11
12
chdir(__DIR__);
13
require_once __DIR__ . '/../vendor/autoload.php';
14
15
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
16
$status = 0;
17
echo "Testing phpFastCacheAbstractProxy class\n";
18
19
/**
20
 * Dynamic driver-based example
21
 * Class myCustomCacheClass
22
 * @package MyCustom\Project
23
 */
24
class CustomMemcachedCacheClass extends phpFastCacheAbstractProxy
25
{
26
    public function __construct($driver = '', array $config = [])
27
    {
28
        global $defaultDriver;
29
        $driver = $defaultDriver;
30
        parent::__construct($driver, $config);
31
        /**
32
         * That's all !! Your cache class is ready to use
33
         */
34
    }
35
}
36
37
38
/**
39
 * Testing memcached as it is declared in .travis.yml
40
 */
41
$driverInstance = new CustomMemcachedCacheClass();
42
43
if (!is_object($driverInstance->getItem('test'))) {
44
    echo '[FAIL] $driverInstance->getItem() returned an invalid var type:' . gettype($driverInstance) . "\n";
45
    $status = 1;
46
}else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){
47
    echo '[FAIL] $driverInstance->getItem() returned an invalid class that does not implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n";
48
    $status = 1;
49
}else{
50
    echo '[PASS] $driverInstance->getItem() returned a valid class that implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n";
51
}
52
53
exit($status);