Completed
Push — develop ( 141adb...8f70d4 )
by Jaap
05:39
created

ConfigureCache::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
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