Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
91.67% |
11 / 12 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
PageLogicBase | |
91.67% |
11 / 12 |
|
66.67% |
2 / 3 |
4.01 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAuditUserInfo | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
2.01 | |||
addTemporaryMessage | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page; |
6 | |
7 | use PeServer\App\Models\Domain\DomainLogicBase; |
8 | use PeServer\App\Models\IAuditUserInfo; |
9 | use PeServer\App\Models\Data\SessionAccount; |
10 | use PeServer\App\Models\SessionKey; |
11 | use PeServer\Core\Mvc\LogicParameter; |
12 | |
13 | abstract class PageLogicBase extends DomainLogicBase |
14 | { |
15 | #region define |
16 | |
17 | public const TEMP_MESSAGES = 'temp_messages'; |
18 | |
19 | #endregion |
20 | |
21 | public function __construct(LogicParameter $parameter) |
22 | { |
23 | parent::__construct($parameter); |
24 | } |
25 | |
26 | #region function |
27 | |
28 | protected function getAuditUserInfo(): ?IAuditUserInfo |
29 | { |
30 | if (!$this->existsSession(SessionKey::ACCOUNT)) { |
31 | return null; |
32 | } |
33 | |
34 | $account = $this->requireSession(SessionKey::ACCOUNT); |
35 | |
36 | return new class ($account) implements IAuditUserInfo |
37 | { |
38 | private string $userId; |
39 | |
40 | public function __construct(SessionAccount $account) |
41 | { |
42 | $this->userId = $account->userId; |
43 | } |
44 | |
45 | public function getUserId(): string |
46 | { |
47 | return $this->userId; |
48 | } |
49 | }; |
50 | } |
51 | |
52 | protected function addTemporaryMessage(string $message): void |
53 | { |
54 | /** @var string[] */ |
55 | $messages = $this->peekTemporary(self::TEMP_MESSAGES, []); |
56 | $messages[] = $message; |
57 | $this->pushTemporary(self::TEMP_MESSAGES, $messages); |
58 | } |
59 | |
60 | #endregion |
61 | } |