Completed
Pull Request — 2.x (#29)
by Akihito
01:35
created

OptionProvider::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * This file is part of the Madapaja.TwigModule package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace Madapaja\TwigModule;
8
9
use BEAR\AppMeta\AbstractAppMeta;
10
use Ray\Di\Di\Named;
11
use Ray\Di\ProviderInterface;
12
13
class OptionProvider implements ProviderInterface
14
{
15
    /**
16
     * @var AbstractAppMeta
17
     */
18
    private $appMeta;
19
20
    /**
21
     * @var bool
22
     */
23
    private $isDebug;
24
25
    /**
26
     * @Named("isDebug=Madapaja\TwigModule\Annotation\TwigDebug")
27
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
28
     */
29
    public function __construct(AbstractAppMeta $appMeta, bool $isDebug = false)
30
    {
31
        $this->appMeta = $appMeta;
32
        $this->isDebug = $isDebug;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function get()
39
    {
40
        $tmpDir = $this->appMeta->tmpDir . '/twig';
41
        ! \file_exists($tmpDir) && \mkdir($tmpDir);
42
        $options = [
43
            'debug' => $this->isDebug,
44
            'cache' => $tmpDir
45
        ];
46
47
        return $options;
48
    }
49
}
50