Cache   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 18
c 3
b 0
f 0
dl 0
loc 32
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getCache() 0 18 4
1
<?php
2
3
// Cache.php
4
// IMPORTANT NOTICE: Doctrine Cache is deprecated. 
5
// This file remains for backward compatibility. Do not use it.
6
// Instead, use symfony/cache.
7
#################################################
8
##
9
## PHPLicengine
10
##
11
#################################################
12
## Copyright 2009-{current_year} PHPLicengine
13
## 
14
## Licensed under the Apache License, Version 2.0 (the "License");
15
## you may not use this file except in compliance with the License.
16
## You may obtain a copy of the License at
17
##
18
##    http://www.apache.org/licenses/LICENSE-2.0
19
##
20
## Unless required by applicable law or agreed to in writing, software
21
## distributed under the License is distributed on an "AS IS" BASIS,
22
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
## See the License for the specific language governing permissions and
24
## limitations under the License.
25
#################################################
26
27
namespace PHPLicengine\Cache;
28
use PHPLicengine\Exception\CacheException;
29
30
class Cache {
31
 
32
       private $config;
33
      
34
       public function __construct(array $config)
35
       {
36
              $this->config = $config;       
37
       }
38
39
       /*
40
      This class uses Doctrine Cache. You can look at its doc to add more cache type.
41
      Whatever option you need to setup the cache type, must be passed as array to constructor.
42
      https://www.doctrine-project.org/projects/doctrine-cache/en/1.8/index.html
43
      */
44
       public function getCache()
45
       {
46
              switch ($this->config['type']) {
47
                     case 'apc':
48
                          $cache = new \Doctrine\Common\Cache\ApcuCache();
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Cache\ApcuCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
49
                     break;
50
                     case 'file':
51
                          $cache = new \Doctrine\Common\Cache\FilesystemCache($this->config['path']);
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Cache\FilesystemCache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
52
                     break;
53
                     case 'sqlite3':
54
                          $db = new \SQLite3($this->config['sqlite3_db']);
55
                          $cache = new \Doctrine\Common\Cache\SQLite3Cache($db, $this->config['sqlite3_table']);
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Cache\SQLite3Cache was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56
                     break;
57
                     default:
58
                          throw new CacheException('Invalid cache system');
59
                     break;
60
              } 
61
              return $cache;
62
       }
63
}
64