Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
UserSettings | |
100.00% |
9 / 9 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getUILanguageCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDataLanguageCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTimezone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSetting | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getSetting | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2021 (original work) Open Assessment Technologies SA. |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\tao\model\user\implementation; |
24 | |
25 | use oat\tao\model\user\UserSettingsInterface; |
26 | |
27 | class UserSettings implements UserSettingsInterface |
28 | { |
29 | /** @var array */ |
30 | private $settings = []; |
31 | |
32 | public function __construct(string $timezone, string $uiLanguageCode = null, string $dataLanguageCode = null) |
33 | { |
34 | $this->setSetting(self::TIMEZONE, $timezone); |
35 | $this->setSetting(self::UI_LANGUAGE_CODE, $uiLanguageCode); |
36 | $this->setSetting(self::DATA_LANGUAGE_CODE, $dataLanguageCode); |
37 | } |
38 | |
39 | public function getUILanguageCode(): ?string |
40 | { |
41 | return $this->getSetting(self::UI_LANGUAGE_CODE); |
42 | } |
43 | |
44 | public function getDataLanguageCode(): ?string |
45 | { |
46 | return $this->getSetting(self::DATA_LANGUAGE_CODE); |
47 | } |
48 | |
49 | public function getTimezone(): string |
50 | { |
51 | return $this->getSetting(self::TIMEZONE); |
52 | } |
53 | |
54 | public function setSetting(string $setting, $value): UserSettingsInterface |
55 | { |
56 | $this->settings[$setting] = $value; |
57 | |
58 | return $this; |
59 | } |
60 | |
61 | public function getSetting(string $setting) |
62 | { |
63 | return $this->settings[$setting] ?? null; |
64 | } |
65 | } |