TightConfig   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 12
Bugs 1 Features 4
Metric Value
wmc 6
c 12
b 1
f 4
lcom 0
cbo 1
dl 0
loc 56
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 20 6
1
<?php
2
3
namespace Tight;
4
5
/*
6
 * The MIT License
7
 *
8
 * Copyright 2016 Alejandro Peña Florentín ([email protected]).
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining a copy
11
 * of this software and associated documentation files (the "Software"), to deal
12
 * in the Software without restriction, including without limitation the rights
13
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 * copies of the Software, and to permit persons to whom the Software is
15
 * furnished to do so, subject to the following conditions:
16
 *
17
 * The above copyright notice and this permission notice shall be included in
18
 * all copies or substantial portions of the Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
 * THE SOFTWARE.
27
 */
28
29
/**
30
 * TightConfig class
31
 *
32
 * @author Alejandro Peña Florentín ([email protected])
33
 */
34
class TightConfig extends BaseConfig
35
{
36
37
    /**
38
     * @var string Application base path
39
     */
40
    public $basePath = null;
41
42
    /**
43
     * @var array Smarty settings
44
     */
45
    public $smarty = [
46
        "template_dir" => "./templates/",
47
        "compile_dir" => "./templates_c/",
48
        "config_dir" => "./configs/",
49
        "cache_dir" => "./cache/"
50
    ];
51
    /**
52
     * @var array MVC settings
53
     */
54
    public $mvc = [
55
        "enableRouter" => false,
56
        "indexName" => "Root",
57
        "controller_dir" => "./controllers/",
58
        "model_dir" => "./models/",
59
        "view_dir" => "./views/",
60
    ];
61
62
    /**
63
     * Constructor
64
     * 
65
     * Settings can be passed as an array
66
     * @param array $config Settings
67
     */
68
    public function __construct(array $config = []) {
69
        if (isset($config['basePath'])) {
70
            $this->basePath = $config['basePath'];
71
            unset($config['basePath']);
72
        }
73
        if (isset($config["smarty"])) {
74
            $this->smarty = array_replace_recursive($this->smarty, $config["smarty"]);
75
            unset($config["smarty"]);
76
        }
77
        if (isset($config["mvc"])) {
78
            $this->mvc = array_replace_recursive($this->mvc, $config["mvc"]);
79
            unset($config["mvc"]);
80
        }
81
        // Creates custom config
82
        if (count($config) > 0) {
83
            foreach ($config as $key => $value) {
84
                $this->$key = $value;
85
            }
86
        }
87
    }
88
89
}
90