Lines
75.00%
3 / 4
Methods
75.00%
3 / 4
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getTranslatedFields | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| isSuccess | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getError | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| 27 | readonly class TranslationResult | |
| 28 | { | |
| 29 | /** | |
| 30 | * Constructor. | |
| 31 | * | |
| 32 | * @param array<string, string> $translatedFields Translated fields (fieldName => translatedValue) | |
| 33 | * @param bool $success Whether translation was successful | |
| 34 | * @param string|null $error Error message if translation failed | |
| 35 | */ | |
| 36 | public function __construct( | |
| 37 | private array $translatedFields, | |
| 38 | private bool $success, | |
| 39 | private ?string $error = null, | |
| 40 | ) { | |
| 41 | } | |
| 42 | ||
| 43 | /** | |
| 44 | * Get translated fields. | |
| 45 | * | |
| 46 | * @return array<string, string> | |
| 47 | */ | |
| 48 | public function getTranslatedFields(): array | |
| 49 | { | |
| 50 | return $this->translatedFields; | |
| 51 | } | |
| 52 | ||
| 53 | /** | |
| 54 | * Check if the translation was successful. | |
| 55 | * | |
| 56 | * @return bool | |
| 57 | */ | |
| 58 | public function isSuccess(): bool | |
| 59 | { | |
| 60 | return $this->success; | |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Get error message. | |
| 65 | * | |
| 66 | * @return string|null | |
| 67 | */ | |
| 68 | public function getError(): ?string | |
| 69 | { | |
| 70 | return $this->error; | |
| 71 | } | |
| 72 | } |