Upgrade to 3.1.3

This commit is contained in:
Bastian Allgeier
2019-04-23 16:13:26 +02:00
parent eb29ef6d6c
commit 066913cb6e
53 changed files with 606 additions and 261 deletions

View File

@@ -46,7 +46,7 @@ class Language extends Model
protected $direction;
/**
* @var string
* @var array
*/
protected $locale;
@@ -293,13 +293,18 @@ class Language extends Model
}
/**
* Returns the PHP locale setting string
* Returns the PHP locale setting array
*
* @return string
* @param int $category If passed, returns the locale for the specified category (e.g. LC_ALL) as string
* @return array|string
*/
public function locale(): string
public function locale(int $category = null)
{
return $this->locale;
if ($category !== null) {
return $this->locale[$category] ?? $this->locale[LC_ALL] ?? null;
} else {
return $this->locale;
}
}
/**
@@ -401,12 +406,21 @@ class Language extends Model
}
/**
* @param string $locale
* @param string|array $locale
* @return self
*/
protected function setLocale(string $locale = null): self
protected function setLocale($locale = null): self
{
$this->locale = $locale ?? $this->code;
if (is_array($locale)) {
$this->locale = $locale;
} elseif (is_string($locale)) {
$this->locale = [LC_ALL => $locale];
} elseif ($locale === null) {
$this->locale = [LC_ALL => $this->code];
} else {
throw new InvalidArgumentException('Locale must be string or array');
}
return $this;
}