nur-sery/nur_src/ldap/labels.php

24 lines
570 B
PHP
Raw Normal View History

2024-04-29 16:39:43 +04:00
<?php
namespace nur\ldap;
use nur\str;
class labels {
static function strip(?string &$value, ?string &$label=null): void {
if ($value === null) return;
if (preg_match('/^(\{[^}]*})/', $value, $ms, PREG_OFFSET_CAPTURE)) {
$label = $ms[1][0];
$value = substr($value, $ms[1][1] + strlen($label));
}
}
static function add(?string $value, ?string $label): ?string {
if ($value === null) return null;
if ($label !== null) {
str::add_prefix($label, "{");
str::add_suffix($label, "}");
}
return "$label$value";
}
}