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 __construct( array $translations ): mixed
$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 translate( string $property ): string
$property string

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