Skip to content

Instantly share code, notes, and snippets.

@kernusr
Created April 15, 2021 22:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kernusr/5da7782864e3326eb3658f06e1cfe16e to your computer and use it in GitHub Desktop.
Save kernusr/5da7782864e3326eb3658f06e1cfe16e to your computer and use it in GitHub Desktop.
Человекопонятные названия атрибутов
<?php
abstract class BaseTagsTranslations implements TagsTranslationsInterface{
static function getTagTranslation(string $key): string
{
switch ($key):
case 'UnstructuredName':
case 'UN':
return 'Неструктурированное имя';
case 'C':
return 'Страна';
case 'S':
return 'Регион';
case 'STREET':
return 'Адрес';
case 'O':
return 'Компания';
case 'T':
return 'Должность';
case 'ОГРН':
case 'OGRN':
return 'ОГРН';
case 'ОГРНИП':
case 'OGRNIP':
return 'ОГРНИП';
case 'СНИЛС':
case 'SNILS':
return 'СНИЛС';
case 'ИНН':
case 'INN':
case 'ИНН организации':
return 'ИНН';
case 'E':
return 'Email';
case 'L':
return 'Город';
default:
return $key;
endswitch;
}
}
<?php
final class IssuerTagsTranslations extends BaseTagsTranslations
{
static function getTagTranslation(string $key): string
{
$transliteration = parent::getTagTranslation($key);
if ($transliteration !== $key)
{
return $transliteration;
}
switch ($key):
case 'CN':
return 'Удостоверяющий центр';
case 'OU':
return 'Тип';
default:
return $key;
endswitch;
}
}
<?php
final class SubjectTagsTranslations extends BaseTagsTranslations
{
static function getTagTranslation(string $key): string
{
$translations = parent::getTagTranslation($key);
if ($translations !== $key)
{
return $translations;
}
switch ($key):
case 'CN':
return 'Владелец';
case 'SN':
return 'Фамилия';
case 'G':
return 'Имя Отчество';
case 'OU':
return 'Отдел/подразделение';
default:
return $key;
endswitch;
}
}
<?php
interface TagsTranslationsInterface
{
static function getTagTranslation(string $key): string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment