Language   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 18
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A translate() 0 4 2
A using() 0 3 1
A load() 0 4 1
1
<?php
2
3
/**
4
 * Language
5
 *
6
 * Localization tools.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @version 0.1 * @copyright Caffeina srl - 2015 - http://caffeina.it
11
 */
12
13
 class Language extends Dictionary {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
14
    use Module;
15
    protected static $current_lang = 'en';
16
17
    public static function translate($text,$params=null){
18
      $result = static::get(static::$current_lang.'.'.strtolower($text),$text);
19
      return $params ? Text::render($result) : $result;
20
    }
21
22
    public static function using($lang){
23
      static::$current_lang = strtolower(trim($lang));
24
    }
25
26
    public static function load($lang, $dictfile){
27
      ob_start(); $lang = include($dictfile); ob_end_clean();
28
      static::merge([$lang => $dictfile]);
29
    }
30
}
31