Passed
Push — main ( 04a742...5b603f )
by
unknown
04:37 queued 12s
created

ExtensionConfiguration::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Aoe\Restler\Configuration;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2021 AOE GmbH <[email protected]>
9
 *
10
 *  All rights reserved
11
 *
12
 *  This script is part of the TYPO3 project. The TYPO3 project is
13
 *  free software; you can redistribute it and/or modify
14
 *  it under the terms of the GNU General Public License as published by
15
 *  the Free Software Foundation; either version 3 of the License, or
16
 *  (at your option) any later version.
17
 *
18
 *  The GNU General Public License can be found at
19
 *  http://www.gnu.org/copyleft/gpl.html.
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28
29
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration as Typo3ExtensionConfiguration;
30
use TYPO3\CMS\Core\SingletonInterface;
31
use TYPO3\CMS\Core\Utility\GeneralUtility;
32
33
/**
34
 * @package Restler
35
 */
36
class ExtensionConfiguration implements SingletonInterface
37
{
38
    /**
39
     * @var array
40
     */
41
    private $configuration = [];
42
43
    /**
44
     * constructor - loading the current localconf configuration for restler extension
45
     */
46 4
    public function __construct(Typo3ExtensionConfiguration $configuration = null)
47
    {
48 4
        if ($configuration === null) {
49
            $configuration = GeneralUtility::makeInstance(TYPO3ExtensionConfiguration::class);
50
        }
51
52 4
        $this->configuration = $configuration->get('restler');
53 4
    }
54
55 1
    public function isCacheRefreshingEnabled(): bool
56
    {
57 1
        return (bool) $this->get('refreshCache');
58
    }
59
60 1
    public function isProductionContextSet(): bool
61
    {
62 1
        return (bool) $this->get('productionContext');
63
    }
64
65 1
    public function isOnlineDocumentationEnabled(): bool
66
    {
67 1
        return (bool) $this->get('enableOnlineDocumentation');
68
    }
69
70 1
    public function getPathOfOnlineDocumentation(): string
71
    {
72 1
        return $this->get('pathToOnlineDocumentation');
73
    }
74
75
    /**
76
     * returns configuration value for the given key
77
     */
78 4
    private function get(string $key): string
79
    {
80 4
        return $this->configuration[$key];
81
    }
82
}
83