repod/lib/Service/UserService.php
Michel Roux 1d8ea08798
All checks were successful
repod / xml (push) Successful in 22s
repod / php (push) Successful in 1m15s
repod / nodejs (push) Successful in 1m6s
repod / release (push) Has been skipped
style: 🎨 add nextcloud/rector
2024-11-12 10:11:21 +01:00

39 lines
733 B
PHP

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