Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| TaskElementMapper | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 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\AccountMapper; |
| 18 | use Modules\Media\Models\MediaMapper; |
| 19 | use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; |
| 20 | |
| 21 | /** |
| 22 | * Mapper class. |
| 23 | * |
| 24 | * @package Modules\Tasks\Models |
| 25 | * @license OMS License 2.0 |
| 26 | * @link https://jingga.app |
| 27 | * @since 1.0.0 |
| 28 | * |
| 29 | * @template T of TaskElement |
| 30 | * @extends DataMapperFactory<T> |
| 31 | */ |
| 32 | final class TaskElementMapper extends DataMapperFactory |
| 33 | { |
| 34 | /** |
| 35 | * Columns. |
| 36 | * |
| 37 | * @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}> |
| 38 | * @since 1.0.0 |
| 39 | */ |
| 40 | public const COLUMNS = [ |
| 41 | 'task_element_id' => ['name' => 'task_element_id', 'type' => 'int', 'internal' => 'id'], |
| 42 | 'task_element_desc' => ['name' => 'task_element_desc', 'type' => 'string', 'internal' => 'description'], |
| 43 | 'task_element_desc_raw' => ['name' => 'task_element_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'], |
| 44 | 'task_element_status' => ['name' => 'task_element_status', 'type' => 'int', 'internal' => 'status'], |
| 45 | 'task_element_priority' => ['name' => 'task_element_priority', 'type' => 'int', 'internal' => 'priority'], |
| 46 | 'task_element_due' => ['name' => 'task_element_due', 'type' => 'DateTime', 'internal' => 'due'], |
| 47 | 'task_element_task' => ['name' => 'task_element_task', 'type' => 'int', 'internal' => 'task'], |
| 48 | 'task_element_created_by' => ['name' => 'task_element_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], |
| 49 | 'task_element_created_at' => ['name' => 'task_element_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], |
| 50 | ]; |
| 51 | |
| 52 | /** |
| 53 | * Has many relation. |
| 54 | * |
| 55 | * @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}> |
| 56 | * @since 1.0.0 |
| 57 | */ |
| 58 | public const HAS_MANY = [ |
| 59 | 'media' => [ |
| 60 | 'mapper' => MediaMapper::class, |
| 61 | 'table' => 'task_element_media', |
| 62 | 'external' => 'task_element_media_dst', |
| 63 | 'self' => 'task_element_media_src', |
| 64 | ], |
| 65 | 'accRelation' => [ |
| 66 | 'mapper' => AccountRelationMapper::class, |
| 67 | 'table' => 'task_account', |
| 68 | 'self' => 'task_account_task_element', |
| 69 | 'external' => null, |
| 70 | ], |
| 71 | 'grpRelation' => [ |
| 72 | 'mapper' => GroupRelationMapper::class, |
| 73 | 'table' => 'task_group', |
| 74 | 'self' => 'task_group_task_element', |
| 75 | 'external' => null, |
| 76 | ], |
| 77 | ]; |
| 78 | |
| 79 | /** |
| 80 | * Belongs to. |
| 81 | * |
| 82 | * @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}> |
| 83 | * @since 1.0.0 |
| 84 | */ |
| 85 | public const BELONGS_TO = [ |
| 86 | 'createdBy' => [ |
| 87 | 'mapper' => AccountMapper::class, |
| 88 | 'external' => 'task_element_created_by', |
| 89 | ], |
| 90 | ]; |
| 91 | |
| 92 | /** |
| 93 | * Primary table. |
| 94 | * |
| 95 | * @var string |
| 96 | * @since 1.0.0 |
| 97 | */ |
| 98 | public const TABLE = 'task_element'; |
| 99 | |
| 100 | /** |
| 101 | * Created at. |
| 102 | * |
| 103 | * @var string |
| 104 | * @since 1.0.0 |
| 105 | */ |
| 106 | public const CREATED_AT = 'task_element_created_at'; |
| 107 | |
| 108 | /** |
| 109 | * Primary field name. |
| 110 | * |
| 111 | * @var string |
| 112 | * @since 1.0.0 |
| 113 | */ |
| 114 | public const PRIMARYFIELD = 'task_element_id'; |
| 115 | } |