Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
TagMapper
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\Tag\Models
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace Modules\Tag\Models;
16
17use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
18
19/**
20 * Tag mapper class.
21 *
22 * @package Modules\Tag\Models
23 * @license OMS License 2.0
24 * @link    https://jingga.app
25 * @since   1.0.0
26 *
27 * @template T of Tag
28 * @extends DataMapperFactory<T>
29 */
30final class TagMapper extends DataMapperFactory
31{
32    /**
33     * Columns.
34     *
35     * @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
36     * @since 1.0.0
37     */
38    public const COLUMNS = [
39        'tag_id'    => ['name' => 'tag_id',    'type' => 'int',    'internal' => 'id'],
40        'tag_color' => ['name' => 'tag_color', 'type' => 'string', 'internal' => 'color'],
41        'tag_icon'  => ['name' => 'tag_icon',  'type' => 'string', 'internal' => 'icon'],
42        'tag_type'  => ['name' => 'tag_type',  'type' => 'int',    'internal' => 'type'],
43        'tag_owner' => ['name' => 'tag_owner', 'type' => 'int',    'internal' => 'owner'],
44    ];
45
46    /**
47     * Has many relation.
48     *
49     * @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
50     * @since 1.0.0
51     */
52    public const HAS_MANY = [
53        'title' => [
54            'mapper'   => TagL11nMapper::class,
55            'table'    => 'tag_l11n',
56            'self'     => 'tag_l11n_tag',
57            'column'   => 'content',
58            'external' => null,
59        ],
60    ];
61
62    /**
63     * Belongs to.
64     *
65     * @var array<string, array{mapper:class-string, self:string}>
66     * @since 1.0.0
67     */
68    /*
69    public const BELONGS_TO = [
70        'owner' => [
71            'mapper' => AccountMapper::class,
72            'external'   => 'tag_owner',
73        ],
74    ];
75    */
76
77    /**
78     * Model to use by the mapper.
79     *
80     * @var class-string<T>
81     * @since 1.0.0
82     */
83    public const MODEL = Tag::class;
84
85    /**
86     * Primary table.
87     *
88     * @var string
89     * @since 1.0.0
90     */
91    public const TABLE = 'tag';
92
93    /**
94     * Primary field name.
95     *
96     * @var string
97     * @since 1.0.0
98     */
99    public const PRIMARYFIELD = 'tag_id';
100}