Using Core Translator in Locale Manager, type hinted its methods and removed unnecessary phpdoc

This commit is contained in:
Daniel Klabbers 2017-11-27 14:03:45 +01:00
parent 4d9e2335c7
commit 55b945f129

View File

@ -11,8 +11,6 @@
namespace Flarum\Locale;
use Illuminate\Contracts\Translation\Translator;
class LocaleManager
{
/**
@ -26,52 +24,49 @@ class LocaleManager
protected $css = [];
/**
* @param Translator $translator
*/
public function __construct(Translator $translator)
{
$this->translator = $translator;
}
public function getLocale()
public function getLocale(): string
{
return $this->translator->getLocale();
}
public function setLocale($locale)
public function setLocale(string $locale)
{
$this->translator->setLocale($locale);
}
public function addLocale($locale, $name)
public function addLocale(string $locale, string $name)
{
$this->locales[$locale] = $name;
}
public function getLocales()
public function getLocales(): array
{
return $this->locales;
}
public function hasLocale($locale)
public function hasLocale(string $locale): bool
{
return isset($this->locales[$locale]);
}
public function addTranslations($locale, $file, $module = null)
public function addTranslations(string $locale, $file, string $module = null)
{
$prefix = $module ? $module.'::' : '';
$this->translator->addResource('prefixed_yaml', compact('file', 'prefix'), $locale);
}
public function addJsFile($locale, $js)
public function addJsFile(string $locale, string $js)
{
$this->js[$locale][] = $js;
}
public function getJsFiles($locale)
public function getJsFiles(string $locale): array
{
$files = array_get($this->js, $locale, []);
@ -84,12 +79,12 @@ class LocaleManager
return $files;
}
public function addCssFile($locale, $css)
public function addCssFile(string $locale, string $css)
{
$this->css[$locale][] = $css;
}
public function getCssFiles($locale)
public function getCssFiles(string $locale): array
{
$files = array_get($this->css, $locale, []);
@ -102,18 +97,12 @@ class LocaleManager
return $files;
}
/**
* @return SymfonyTranslator
*/
public function getTranslator()
public function getTranslator(): Translator
{
return $this->translator;
}
/**
* @param SymfonyTranslator $translator
*/
public function setTranslator(SymfonyTranslator $translator)
public function setTranslator(Translator $translator)
{
$this->translator = $translator;
}