Passed
Branch main (a47c5a)
by AOEPeople
15:53 queued 02:59
created

Tx_FeatureFlag_System_Typo3_Configuration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getTables() 0 3 1
A get() 0 6 2
1
<?php
2
3
/***************************************************************
4
 *  Copyright notice
5
 *
6
 *  (c) 2016 AOE GmbH <[email protected]>
7
 *
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
/**
28
 * @package FeatureFlag
29
 * @subpackage System_Typo3
30
 */
31
class Tx_FeatureFlag_System_Typo3_Configuration
32
{
33
    /**
34
     * @var string
35
     */
36
    const CONF_TABLES = 'tables';
37
38
    /**
39
     * @var array
40
     */
41
    private $configuration = array();
42
43
    /**
44
     * Initialize configuration array
45
     */
46
    public function __construct()
47
    {
48
        $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['feature_flag']);
49
        if (is_array($conf)) {
50
            $this->configuration = $conf;
51
        }
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getTables()
58
    {
59
        return explode(',', $this->get(self::CONF_TABLES));
60
    }
61
62
    /**
63
     * @param string $key
64
     * @return mixed
65
     * @throws InvalidArgumentException
66
     */
67
    public function get($key)
68
    {
69
        if (array_key_exists($key, $this->configuration)) {
70
            return $this->configuration[$key];
71
        }
72
        throw new InvalidArgumentException('Configuration key "' . $key . '" does not exist.', 1384161387);
73
    }
74
}
75