MaintainerFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 5
1
<?php
2
3
namespace PhpCache\Storage;
4
5
use Psr\Container\ContainerInterface;
6
7
/**
8
 * Description of MaintainerFactory.
9
 *
10
 * @author dude920228
11
 */
12
class MaintainerFactory
13
{
14
    public function __invoke(ContainerInterface $container)
15
    {
16
        $config = $container->getConfig();
17
        $ttl = 3600;
18
        $backupDir = __DIR__.'/../../.backup';
19
        $backupTime = 3600;
20
        $memoryLimit = 1024;
21
        if (array_key_exists('ttl', $config)) {
22
            $ttl = $config['ttl'];
23
        }
24
        if (array_key_exists('backupDir', $config)) {
25
            $backupDir = $config['backupDir'];
26
        }
27
        if (array_key_exists('backupTime', $config)) {
28
            $backupTime = $config['backupTime'];
29
        }
30
        if (array_key_exists('memoryLimit', $config)) {
31
            $memoryLimit = $config['memoryLimit'];
32
        }
33
34
        return new Maintainer($ttl, $backupDir, $backupTime, $memoryLimit);
35
    }
36
}
37