Passed
Pull Request — development (#3540)
by Emanuele
07:11
created

Txt   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 16 3
1
<?php
2
3
/**
4
 * Class related to load multiple languages and keep relation with global variables
5
 *
6
 * @package   ElkArte Forum
7
 * @copyright ElkArte Forum contributors
8
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
9
 *
10
 * @version 2.0 dev
11
 *
12
 */
13
14
namespace ElkArte\Languages;
15
16
use ElkArte\User;
17
18
/**
19
 * This class allows to keep track of the languages loaded and push the values to
20
 * global variables to maintain a balance between the "old" and the "new".
21
 */
22
class Txt
23
{
24
	/** @var Loader[] */
25
	protected static $loader = null;
26
27
	public static function load($template, $fatal = true, $fix_calendar_arrays = false)
28
	{
29
		global $txt, $language, $modSettings;
30
31
		if (self::$loader === null)
0 ignored issues
show
introduced by
The condition self::loader === null is always false.
Loading history...
32
		{
33
			$txt = [];
34
			$lang = User::$info->language ?? $language;
35
			self::$loader = new Loader($lang, $txt, database());
36
			self::$loader->setFallback(empty($modSettings['disable_language_fallback']));
37
		}
38
		if (is_array($template))
39
		{
40
			$template = implode('+', $template);
41
		}
42
		self::$loader->load($template, $fatal, $fix_calendar_arrays);
43
	}
44
}