aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/commerceguys/intl/src/Language/Language.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/commerceguys/intl/src/Language/Language.php')
-rw-r--r--vendor/commerceguys/intl/src/Language/Language.php71
1 files changed, 36 insertions, 35 deletions
diff --git a/vendor/commerceguys/intl/src/Language/Language.php b/vendor/commerceguys/intl/src/Language/Language.php
index 9958d5481..d8196f26c 100644
--- a/vendor/commerceguys/intl/src/Language/Language.php
+++ b/vendor/commerceguys/intl/src/Language/Language.php
@@ -2,7 +2,10 @@
namespace CommerceGuys\Intl\Language;
-class Language implements LanguageEntityInterface
+/**
+ * Represents a language.
+ */
+final class Language
{
/**
* The two-letter language code.
@@ -19,42 +22,56 @@ class Language implements LanguageEntityInterface
protected $name;
/**
- * The language locale (i.e. "en-US").
+ * The locale (i.e. "en-US").
*
* @var string
*/
protected $locale;
/**
- * Returns the string representation of the Language.
+ * Creates a new Language instance.
*
- * @return string
+ * @param array $definition The definition array.
*/
- public function __toString()
+ public function __construct(array $definition)
{
- return $this->getLanguageCode();
+ foreach (['language_code', 'name', 'locale'] as $requiredProperty) {
+ if (empty($definition[$requiredProperty])) {
+ throw new \InvalidArgumentException(sprintf('Missing required property "%s".', $requiredProperty));
+ }
+ }
+
+ $this->languageCode = $definition['language_code'];
+ $this->name = $definition['name'];
+ $this->locale = $definition['locale'];
}
/**
- * {@inheritdoc}
+ * Returns the string representation of the Language.
+ *
+ * @return string
*/
- public function getLanguageCode()
+ public function __toString()
{
return $this->languageCode;
}
/**
- * {@inheritdoc}
+ * Gets the two-letter language code.
+ *
+ * @return string
*/
- public function setLanguageCode($languageCode)
+ public function getLanguageCode()
{
- $this->languageCode = $languageCode;
-
- return $this;
+ return $this->languageCode;
}
/**
- * {@inheritdoc}
+ * Gets the language name.
+ *
+ * This value is locale specific.
+ *
+ * @return string
*/
public function getName()
{
@@ -62,30 +79,14 @@ class Language implements LanguageEntityInterface
}
/**
- * {@inheritdoc}
- */
- public function setName($name)
- {
- $this->name = $name;
-
- return $this;
- }
-
- /**
- * {@inheritdoc}
+ * Gets the locale.
+ *
+ * The language name is locale specific.
+ *
+ * @return string
*/
public function getLocale()
{
return $this->locale;
}
-
- /**
- * {@inheritdoc}
- */
- public function setLocale($locale)
- {
- $this->locale = $locale;
-
- return $this;
- }
}