@@ -396,30 +396,6 @@ public function removeAttributeEntryByValue(string $attr, mixed $value): void
396396 $ this ->mods [$ attr ] = array_values ($ arr );
397397 }
398398
399- /**
400- * converts an attribute value in its multi-valued form to the requested form
401- * @param array $value
402- * @param bool $multi_valued
403- * returns $value unmolested if $multi_valued
404- * returns null if !$multi_valued and count($value) == 0
405- * returns mixed if !$multi_valued and count($value) == 1
406- * @throws ValueError if !$multi_valued and count($value) > 1
407- */
408- private function convertSingleOrMultiValued (array $ value , bool $ multi_valued ): mixed
409- {
410- if ($ multi_valued ) {
411- return $ value ;
412- }
413- $ count = count ($ value );
414- if ($ count == 0 ) {
415- return null ;
416- }
417- if ($ count == 1 ) {
418- return $ value [0 ];
419- }
420- throw new ValueError ("cannot convert array of length $ count to single value! " );
421- }
422-
423399 /**
424400 * Returns a given attribute of the object
425401 *
@@ -443,7 +419,6 @@ public function getAttribute(string $attr, bool $multi_valued = true): mixed
443419 return $ this ->convertSingleOrMultiValued ([], $ multi_valued );
444420 }
445421
446-
447422 /**
448423 * Checks if entry has an attribute
449424 *
@@ -482,4 +457,28 @@ public function pendingChanges(): bool
482457 {
483458 return !is_null ($ this ->mods );
484459 }
460+
461+ /**
462+ * converts an attribute value in its multi-valued form to the requested form
463+ * @param array $value
464+ * @param bool $multi_valued
465+ * returns $value unmolested if $multi_valued
466+ * returns null if !$multi_valued and count($value) == 0
467+ * returns mixed if !$multi_valued and count($value) == 1
468+ * @throws ValueError if !$multi_valued and count($value) > 1
469+ */
470+ private function convertSingleOrMultiValued (array $ value , bool $ multi_valued ): mixed
471+ {
472+ if ($ multi_valued ) {
473+ return $ value ;
474+ }
475+ $ count = count ($ value );
476+ if ($ count == 0 ) {
477+ return null ;
478+ }
479+ if ($ count == 1 ) {
480+ return $ value [0 ];
481+ }
482+ throw new ValueError ("cannot convert array of length $ count to single value! " );
483+ }
485484}
0 commit comments