Language   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 23 3
A get() 0 3 2
1
<?php
2
3
/**
4
 * KNUT7 K7F (https://marciozebedeu.com/)
5
 * KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @link      https://github.com/knut7/framework/ for the canonical source repository
12
 * @copyright (c) 2015.  KNUT7  Software Technologies AO Inc. (https://marciozebedeu.com/)
13
 * @license   https://marciozebedeu.com/license/new-bsd New BSD License
14
 * @author    Marcio Zebedeu - [email protected]
15
 * @version   1.0.2
16
 */
17
18
/**
19
 * Language - simple language handler.
20
 *
21
 * @author Bartek Kuśmierczuk - [email protected] - http://qsma.pl
22
 * @version 2.2
23
 * @date November 18, 2014
24
 * @date updated Sept 19, 2015
25
 */
26
27
namespace Ballybran\Core\Language;
28
29
use Ballybran\Core\Language\LanguageInterface;
30
use Ballybran\Exception\Exception;
31
use Ballybran\Helpers\vardump\Vardump;
0 ignored issues
show
Bug introduced by
The type Ballybran\Helpers\vardump\Vardump was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
33
/**
34
 * Language class to load the requested language file.
35
 */
36
class Language implements LanguageInterface
37
{
38
39
40
    private $default = 'en';
41
    private $data = array();
42
43
    public function get($key)
44
    {
45
        return (isset($this->data[$key]) ? $this->data[$key] : $key);
46
    }
47
48
    public function set($filename, $Language = null)
49
    {
50
        $_ = array();
51
52
53
        $file = __DIR__ . '/../../' . DIR_LANGUAGE . $this->default . '/' . $filename . '.php';
54
55
56
        if (is_file($file)) {
57
            require($file);
58
        }
59
60
        $file = __DIR__ . '/../../' . DIR_LANGUAGE . $Language . '/' . $filename . '.php';
61
//        Vardump::dumpColor($file);
62
63
64
        if (is_file($file)) {
65
            require($file);
66
        }
67
68
        $this->data = array_merge($this->data, $_);
69
70
        return $this->data;
71
    }
72
73
}
74