24 lines
		
	
	
		
			570 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			570 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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";
 | |
|   }
 | |
| }
 |