Completed
Push — 7.4 ( 310a44...3b2076 )
by Nikolaos
05:19
created

CacheFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 33
ccs 6
cts 6
cp 1
c 0
b 0
f 0
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * (c) Phalcon Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Phalcon\Cache;
15
16
use Phalcon\Cache;
17
use Phalcon\Factory\Exception as FactoryException;
18
19
/**
20
 * Creates a new Cache class
21
 *
22
 * @property AdapterFactory $adapterFactory
23
 */
24
class CacheFactory
25
{
26
    /**
27
     * @var AdapterFactory
28
     */
29
    protected AdapterFactory $adapterFactory;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
30
31
    /**
32
     * CacheFactory constructor.
33
     *
34
     * @param AdapterFactory $factory
35
     */
36 1
    public function __construct(AdapterFactory $factory)
37
    {
38 1
        $this->adapterFactory = $factory;
39 1
    }
40
41
    /**
42
     * Constructs a new Cache instance.
43
     *
44
     * @param string $name
45
     * @param array  $options
46
     *
47
     * @return Cache
48
     * @throws FactoryException
49
     */
50 1
    public function newInstance(string $name, array $options = []): Cache
51
    {
52 1
        $adapter = $this->adapterFactory->newInstance($name, $options);
53
54 1
        return new Cache($adapter);
55
    }
56
}
57