0 follower

Final Class Yiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator

InheritanceYiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator
ImplementsYiisoft\Validator\PropertyTranslatorInterface

A property translator that uses array of translations.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( array $translations )
$translations array

Translations array where each key is a property name and the corresponding value is a translation.

                public function __construct(
    private array $translations,
) {}

            
translate() public method

public string translate ( string $property )
$property string

                public function translate(string $property): string
{
    return $this->translations[$property] ?? $property;
}