RequestCacheFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
/**
4
 * This file is part of the bugloos/fault-tolerance-bundle project.
5
 * (c) Bugloos <https://bugloos.com/>
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Bugloos\FaultToleranceBundle\Factory;
11
12
use Bugloos\FaultToleranceBundle\RequestCache\RequestCache;
13
use Bugloos\FaultToleranceBundle\RequestCache\Storage\CacheStorageFactory;
14
use Exception;
15
16
/**
17
 * @author Mojtaba Gheytasi <[email protected]>
18
 */
19
class RequestCacheFactory
20
{
21
    private CacheStorageFactory $storageFactory;
22
23
    public function __construct(CacheStorageFactory $storageFactory)
24
    {
25
        $this->storageFactory = $storageFactory;
26
    }
27
28
    /**
29
     * @throws Exception
30
     */
31
    public function create(string $storageType): RequestCache
32
    {
33
        $storage = $this->storageFactory->create($storageType);
34
35
        return new RequestCache($storage);
36
    }
37
}
38