1: <?php
2: /**
3: * PHP version 5
4: * @package generalDriver
5: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
6: * @author Stefan Heimes <stefan_heimes@hotmail.com>
7: * @author Tristan Lins <tristan.lins@bit3.de>
8: * @copyright The MetaModels team.
9: * @license LGPL.
10: * @filesource
11: */
12:
13: namespace DcGeneral\Data;
14:
15: /**
16: * This class is the base implementation for LanguageInformationInterface.
17: *
18: * @package DcGeneral\Data
19: */
20: class DefaultLanguageInformation
21: implements LanguageInformationInterface
22: {
23: /**
24: * The ISO 639 language code.
25: *
26: * @var string
27: */
28: protected $language;
29:
30: /**
31: * The ISO 3166 country code.
32: *
33: * @var string
34: */
35: protected $country;
36:
37: /**
38: * Create a new instance.
39: *
40: * @param string $language The ISO 639 language code.
41: *
42: * @param null|string $country The ISO 3166 country code.
43: */
44: public function __construct($language, $country = null)
45: {
46: $this->language = $language;
47: $this->country = $country;
48: }
49:
50: /**
51: * {@inheritDoc}
52: */
53: public function getLanguageCode()
54: {
55: return $this->language;
56: }
57:
58: /**
59: * {@inheritDoc}
60: */
61: public function getCountryCode()
62: {
63: return $this->country;
64: }
65:
66: /**
67: * {@inheritDoc}
68: */
69: public function getLocale()
70: {
71: if ($this->getCountryCode())
72: {
73: return $this->getLanguageCode() . '_' . $this->getCountryCode();
74: }
75:
76: return $this->getLanguageCode();
77: }
78: }
79: