setLatin($latin); } if (!empty($eastAsia)) { $this->setEastAsia($eastAsia); } if (!empty($bidirectional)) { $this->setBidirectional($bidirectional); } } /** * Set the Latin Language * * @param string $latin * The value for the latin language * @return self */ public function setLatin($latin) { $this->latin = $this->validateLocale($latin); return $this; } /** * Get the Latin Language * * @return string|null */ public function getLatin() { return $this->latin; } /** * Set the Language ID * * @param int $langId * The value for the language ID * @return self * @see https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx */ public function setLangId($langId) { $this->langId = $langId; return $this; } /** * Get the Language ID * * @return int */ public function getLangId() { return $this->langId; } /** * Set the East Asian Language * * @param string $eastAsia * The value for the east asian language * @return self */ public function setEastAsia($eastAsia) { $this->eastAsia = $this->validateLocale($eastAsia); return $this; } /** * Get the East Asian Language * * @return string|null */ public function getEastAsia() { return $this->eastAsia; } /** * Set the Complex Script Language * * @param string $bidirectional * The value for the complex script language * @return self */ public function setBidirectional($bidirectional) { $this->bidirectional = $this->validateLocale($bidirectional); return $this; } /** * Get the Complex Script Language * * @return string|null */ public function getBidirectional() { return $this->bidirectional; } /** * Validates that the language passed is in the format xx-xx * * @param string $locale * @return string */ private function validateLocale($locale) { if ($locale !== null) { $locale = str_replace('_', '-', $locale); } if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale); } if ($locale !== null && $locale !== 'zxx' && strstr($locale, '-') === false) { throw new \InvalidArgumentException($locale . ' is not a valid language code'); } return $locale; } }