21 lines
620 B
PHP
21 lines
620 B
PHP
<?php
|
|
namespace nur\ldap\syntaxes;
|
|
|
|
class PostalAddressSyntax extends StringSyntax {
|
|
function php2ldap($value): ?string {
|
|
$value = parent::php2ldap($value);
|
|
if ($value === null) return null;
|
|
// mettre en échappement tout caractère $
|
|
$value = str_replace('$', '\$', $value);
|
|
$value = preg_replace('/\r?\n/', '$', $value);
|
|
$value = preg_replace('/\s*(?<!\\\\)\$\s*/', ' $ ', $value);
|
|
return $value;
|
|
}
|
|
|
|
function ldap2php(string $value): string {
|
|
$value = preg_replace('/\s*(?<!\\\\)\$\s*/', "\n", $value);
|
|
$value = preg_replace('/\\\\\$/', '$', $value);
|
|
return $value;
|
|
}
|
|
}
|