Base::getLocale()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 * @package Base
7
 * @subpackage Translation
8
 */
9
10
11
namespace Aimeos\Base\Translation\Decorator;
12
13
14
/**
15
 * Base class for all translator decorators.
16
 *
17
 * @package Base
18
 * @subpackage Translation
19
 */
20
abstract class Base
21
	extends \Aimeos\Base\Translation\Base
22
	implements \Aimeos\Base\Translation\Decorator\Iface
23
{
24
	private \Aimeos\Base\Translation\Iface $object;
25
26
27
	/**
28
	 * Initializes the decorator.
29
	 *
30
	 * @param \Aimeos\Base\Translation\Iface $object Translation object or decorator
31
	 */
32
	public function __construct( \Aimeos\Base\Translation\Iface $object )
33
	{
34
		$this->object = $object;
35
	}
36
37
38
	/**
39
	 * Returns the translated string.
40
	 *
41
	 * @param string $domain Translation domain
42
	 * @param string $string String to be translated
43
	 * @return string The translated string
44
	 */
45
	public function dt( string $domain, string $string ) : string
46
	{
47
		return $this->object->dt( $domain, $string );
48
	}
49
50
51
	/**
52
	 * Returns the translated string by the given plural and quantity.
53
	 *
54
	 * @param string $domain Translation domain
55
	 * @param string $singular String in singular form
56
	 * @param string $plural String in plural form
57
	 * @param int $number Quantity to chose the correct plural form for languages with plural forms
58
	 * @return string Returns the translated singular or plural form of the string depending on the given number.
59
	 */
60
	public function dn( string $domain, string $singular, string $plural, int $number ) : string
61
	{
62
		return $this->object->dn( $domain, $singular, $plural, $number );
63
	}
64
65
66
	/**
67
	 * Returns all locale string of the given domain.
68
	 *
69
	 * @param string $domain Translation domain
70
	 * @return array Associative list with original string as key and translation
71
	 * 	as value or an associative list with index => translation as value if
72
	 * 	plural forms are available
73
	 */
74
	public function all( string $domain ) : array
75
	{
76
		return $this->object->all( $domain );
77
	}
78
79
80
	/**
81
	 * Returns the current locale string.
82
	 *
83
	 * @return string ISO locale string
84
	 */
85
	public function getLocale() : string
86
	{
87
		return $this->object->getLocale();
88
	}
89
90
91
	/**
92
	 * Returns the wrapped translation object.
93
	 *
94
	 * @return \Aimeos\Base\Translation\Iface Translation object
95
	 */
96
	protected function object() : \Aimeos\Base\Translation\Iface
97
	{
98
		return $this->object;
99
	}
100
}
101