nur-sery/nur_src/ldap/syntaxes/TelephoneSyntax.php

30 lines
712 B
PHP

<?php
namespace nur\ldap\syntaxes;
use nur\data\types\TelephoneType;
use nur\ldap\labels;
class TelephoneSyntax extends StringSyntax {
function __construct() {
$this->type = new TelephoneType();
}
/** @var TelephoneType */
protected $type;
function php2ldap($value): ?string {
$value = parent::php2ldap($value);
if ($value === null) return null;
labels::strip($value, $label);
$type = $this->type;
$value = $type->ensureInternational($type->with($value));
return labels::add($value, $label);
}
function ldap2php(string $value): string {
labels::strip($value, $label);
$value = $this->type->ensureLocal($value);
return labels::add($value, $label);
}
}