Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
AccountRelation | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getRelation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toArray | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
jsonSerialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Jingga |
4 | * |
5 | * PHP Version 8.1 |
6 | * |
7 | * @package Modules\Tasks\Models |
8 | * @copyright Dennis Eichhorn |
9 | * @license OMS License 2.0 |
10 | * @version 1.0.0 |
11 | * @link https://jingga.app |
12 | */ |
13 | declare(strict_types=1); |
14 | |
15 | namespace Modules\Tasks\Models; |
16 | |
17 | use Modules\Admin\Models\Account; |
18 | use Modules\Admin\Models\NullAccount; |
19 | |
20 | /** |
21 | * Task relation to account |
22 | * |
23 | * @package Modules\Tasks\Models |
24 | * @license OMS License 2.0 |
25 | * @link https://jingga.app |
26 | * @since 1.0.0 |
27 | */ |
28 | class AccountRelation extends RelationAbstract |
29 | { |
30 | /** |
31 | * Relation object |
32 | * |
33 | * @var Account |
34 | * @since 1.0.0 |
35 | */ |
36 | public Account $relation; |
37 | |
38 | /** |
39 | * Constructor. |
40 | * |
41 | * @param null|Account $account Account |
42 | * @param int $duty Duty type |
43 | * |
44 | * @since 1.0.0 |
45 | */ |
46 | public function __construct(Account $account = null, int $duty = DutyType::TO) |
47 | { |
48 | $this->relation = $account ?? new NullAccount(); |
49 | $this->duty = $duty; |
50 | } |
51 | |
52 | /** |
53 | * Get relation object. |
54 | * |
55 | * @return Account |
56 | * |
57 | * @since 1.0.0 |
58 | */ |
59 | public function getRelation() : Account |
60 | { |
61 | return $this->relation; |
62 | } |
63 | |
64 | /** |
65 | * {@inheritdoc} |
66 | */ |
67 | public function toArray() : array |
68 | { |
69 | return [ |
70 | 'id' => $this->id, |
71 | 'duty' => $this->duty, |
72 | 'relation' => $this->relation, |
73 | ]; |
74 | } |
75 | |
76 | /** |
77 | * {@inheritdoc} |
78 | */ |
79 | public function jsonSerialize() : mixed |
80 | { |
81 | return $this->toArray(); |
82 | } |
83 | } |