Passed
Push — master ( c53668...8969dd )
by Jean-Christophe
08:33
created

MessagesCatalog::getMessagesDomains()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ubiquity\translation;
4
5
use Ubiquity\translation\loader\LoaderInterface;
6
7
/**
8
 * Catalog of translation messages associated to a locale.
9
 * Ubiquity\translation$MessagesCatalog
10
 * This class is part of Ubiquity
11
 *
12
 * @author jcheron <[email protected]>
13
 * @version 1.0.0
14
 *
15
 */
16
class MessagesCatalog {
17
	protected $messagesDomains;
18
	/**
19
	 *
20
	 * @var LoaderInterface
21
	 */
22
	protected $loader;
23
	protected $locale;
24
25
	public function __construct($locale, LoaderInterface $loader) {
26
		$this->locale = $locale;
27
		$this->loader = $loader;
28
		$this->messagesDomains = [ ];
29
	}
30
31
	public function load() {
32
		$this->messagesDomains = [ ];
33
		$domains = $this->getDomains ();
34
		foreach ( $domains as $domain ) {
35
			$do = new MessagesDomain ( $this->locale, $this->loader, $domain );
36
			$do->load ();
37
			$this->messagesDomains [] = $do;
38
		}
39
	}
40
41
	public function getDomains() {
42
		return $this->loader->getDomains ( $this->locale );
43
	}
44
45
	/**
46
	 *
47
	 * @return MessagesDomain[]
48
	 */
49
	public function getMessagesDomains() {
50
		return $this->messagesDomains;
51
	}
52
}
53
54