Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (success)
80.00%
4 / 5
80.00% covered (success)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
TranslationRequest
80.00% covered (success)
80.00%
4 / 5
80.00% covered (success)
80.00%
4 / 5
5.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContentType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSourceLang
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTargetLang
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFields
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Data Transfer Object for translation requests.
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public License,
9 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
10 * obtain one at https://mozilla.org/MPL/2.0/.
11 *
12 * @package   phpMyFAQ
13 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
14 * @copyright 2026 phpMyFAQ Team
15 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
16 * @link      https://www.phpmyfaq.de
17 * @since     2026-01-17
18 */
19
20namespace phpMyFAQ\Translation\DTO;
21
22/**
23 * Class TranslationRequest
24 *
25 * DTO for translation requests containing content type, languages, and fields to translate.
26 */
27readonly class TranslationRequest
28{
29    /**
30     * Constructor.
31     *
32     * @param string $contentType Content type ('faq', 'customPage', 'category', 'news')
33     * @param string $sourceLang Source language code (ISO 639-1)
34     * @param string $targetLang Target language code (ISO 639-1)
35     * @param array<string, string> $fields Fields to translate (fieldName => value)
36     */
37    public function __construct(
38        private string $contentType,
39        private string $sourceLang,
40        private string $targetLang,
41        private array $fields,
42    ) {
43    }
44
45    /**
46     * Get content type.
47     *
48     * @return string
49     */
50    public function getContentType(): string
51    {
52        return $this->contentType;
53    }
54
55    /**
56     * Get source language.
57     *
58     * @return string
59     */
60    public function getSourceLang(): string
61    {
62        return $this->sourceLang;
63    }
64
65    /**
66     * Get target language.
67     *
68     * @return string
69     */
70    public function getTargetLang(): string
71    {
72        return $this->targetLang;
73    }
74
75    /**
76     * Get fields to translate.
77     *
78     * @return array<string, string>
79     */
80    public function getFields(): array
81    {
82        return $this->fields;
83    }
84}