. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Elements; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Tree; use function strtoupper; use function view; /** * SEX_VALUE := {Size=1:7} * A code that indicates the sex of the individual */ class SexValue extends AbstractElement { /** * Convert a value to a canonical form. * * @param string $value * * @return string */ public function canonical(string $value): string { return strtoupper(parent::canonical($value)); } /** * Create a default value for this element. * * @param Tree $tree * * @return string */ public function default(Tree $tree): string { return 'U'; } /** * An edit control for this data. * * @param string $id * @param string $name * @param string $value * @param Tree $tree * * @return string */ public function edit(string $id, string $name, string $value, Tree $tree): string { return view('components/radios-inline', [ 'name' => $name, 'options' => $this->values(), 'selected' => $value, ]); } /** * A list of controlled values for this element * * @return array */ public function values(): array { return [ 'M' => I18N::translate('Male'), 'F' => I18N::translate('Female'), 'U' => I18N::translateContext('unknown gender', 'Unknown'), ]; } }