repod/lib/Service/UserService.php
Michel Roux d8241e1ac3
All checks were successful
repod / nextcloud (push) Successful in 44s
repod / nodejs (push) Successful in 1m14s
Refacto again
2023-07-28 03:00:38 +02:00

37 lines
616 B
PHP

<?php
declare(strict_types=1);
namespace OCA\RePod\Service;
use OCP\IUserSession;
use OCP\L10N\IFactory;
class UserService
{
public function __construct(
private IFactory $l10n,
private IUserSession $userSession
) {
}
public function getIsoCode(): string
{
return $this->l10n->getUserLanguage($this->userSession->getUser());
}
public function getCountryCode(): string
{
$isoCodes = explode('_', $this->getIsoCode());
return isset($isoCodes[1]) ? $isoCodes[1] : 'us';
}
public function getLangCode(): string
{
$isoCodes = explode('_', $this->getIsoCode());
return $isoCodes[0];
}
}