Completed
Push — master ( e045b6...635827 )
by
unknown
16:24
created

ExtensionConfiguration::isDebug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace Aoe\Varnish\TYPO3\Configuration;
3
4
use TYPO3\CMS\Core\SingletonInterface;
5
6
class ExtensionConfiguration implements SingletonInterface
7
{
8
    /**
9
     * @var array
10
     */
11
    private $configuration;
12
13 4
    /**
14
     * ExtensionConfiguration constructor.
15 4
     */
16 4
    public function __construct()
17
    {
18
        $this->configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['varnish']);
19
    }
20
21 2
    /**
22
     * @return boolean
23 2
     */
24
    public function isDebug()
25
    {
26
        return (boolean)$this->get('debug');
27
    }
28
29 2
    /**
30
     * @return array
31 2
     */
32 2
    public function getHosts()
33 2
    {
34 2
        $hosts = explode(',', $this->get('hosts'));
35 2
        array_walk($hosts, function (&$value) {
36 2
            if (false === strpos($value, 'https://') && false === strpos($value, 'http://')) {
37 2
                $value = 'http://' . $value;
38
            }
39
        });
40
        return $hosts;
41
    }
42
43
    /**
44 4
     * @return integer
45
     */
46 4
    public function getDefaultTimeout()
47
    {
48
        return (int)$this->get('default_timeout');
49
    }
50
51
    /**
52
     * @return integer
53
     */
54
    public function getBanTimeout()
55
    {
56
        return (int)$this->get('ban_timeout');
57
    }
58
59
    /**
60
     * @param string $key
61
     * @return string
62
     */
63
    private function get($key)
64
    {
65
        return $this->configuration[$key];
66
    }
67
}
68