-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEchoTranslator.php
39 lines (35 loc) · 1.06 KB
/
EchoTranslator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace Flasher\Prime\Translation;
/**
* EchoTranslator - Minimal translator implementation that returns message IDs unchanged.
*
* This implementation simply returns the message identifiers as-is, without
* performing any actual translation. It serves as a fallback translator when
* no real translation service is available.
*
* Design patterns:
* - Null Object: Provides a do-nothing implementation that maintains API compatibility
* - Fallback: Serves as a default implementation when no specific translator is provided
*/
final readonly class EchoTranslator implements TranslatorInterface
{
/**
* {@inheritdoc}
*
* This implementation simply returns the message identifier unchanged.
*/
public function translate(string $id, array $parameters = [], ?string $locale = null): string
{
return $id;
}
/**
* {@inheritdoc}
*
* This implementation always returns 'en' as the default locale.
*/
public function getLocale(): string
{
return 'en';
}
}