Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationStepLogger::bound
Caps every value in a context, naming what was left out.
Arrays are cut to {@see self::MAX_ARRAY_ITEMS} and gain a sibling counting the entries omitted, so a reader can tell a short list from a truncated one. A map of lists, such as the excluded tokens grouped by reason, is cut per list and counted per key.
Метод класса: NotificationStepLogger{}
Хуков нет.
Возвращает
array.
Использование
$result = NotificationStepLogger::bound( $context ): array;
- $context(массив) (обязательный)
- The context.
Код NotificationStepLogger::bound() NotificationStepLogger::bound WC 11.3.0
private static function bound( array $context ): array {
$bounded = array();
foreach ( $context as $key => $value ) {
if ( is_string( $value ) ) {
$bounded[ $key ] = self::clean( $value, self::MAX_VALUE_LENGTH );
continue;
}
if ( ! is_array( $value ) ) {
$bounded[ $key ] = $value;
continue;
}
$omitted = array();
foreach ( $value as $inner_key => $inner ) {
if ( ! is_array( $inner ) ) {
continue;
}
$left = count( $inner ) - self::MAX_ARRAY_ITEMS;
if ( $left > 0 ) {
$value[ $inner_key ] = array_slice( $inner, 0, self::MAX_ARRAY_ITEMS );
$omitted[ $inner_key ] = $left;
}
}
$left = count( $value ) - self::MAX_ARRAY_ITEMS;
if ( empty( $omitted ) && $left > 0 ) {
$value = array_slice( $value, 0, self::MAX_ARRAY_ITEMS );
$omitted = $left;
}
$bounded[ $key ] = $value;
if ( ! empty( $omitted ) ) {
$bounded[ $key . '_omitted' ] = $omitted;
}
}
return $bounded;
}