ConfigureCache   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Application\Stage\Cache;
17
18
use phpDocumentor\Application\Stage\Payload;
19
use RuntimeException;
20
use Stash\Driver\FileSystem;
21
use Stash\Pool;
22
23
final class ConfigureCache
24
{
25
    private $cache;
26
27 4
    public function __construct(Pool $cache)
28
    {
29 4
        $this->cache = $cache;
30 4
    }
31
32
    /**
33
     * Executes the business logic involved with this command.
34
     *
35
     * @throws RuntimeException if the target location is not a folder.
36
     */
37 4
    public function __invoke(Payload $payload): Payload
38
    {
39 4
        $configuration  = $payload->getConfig();
40 4
        $target = (string) $configuration['phpdocumentor']['paths']['cache'];
41 4
        $this->cache->setDriver(new FileSystem(['path' => $target]));
42
43 4
        return $payload;
44
    }
45
}
46