<?php
/**
 * Shared callback-map invoker for extracted admin autonomy runtime helpers.
 *
 * @package Niwa_AI
 */

defined( 'ABSPATH' ) || exit;

class Niwa_AI_Admin_Autonomy_Callbacks {
	public static function call( $callbacks, $name, $args = array(), $default = null ) {
		$callbacks = is_array( $callbacks ) ? $callbacks : array();
		$name      = (string) $name;

		if ( empty( $callbacks[ $name ] ) || ! is_callable( $callbacks[ $name ] ) ) {
			return $default;
		}

		return call_user_func_array( $callbacks[ $name ], is_array( $args ) ? $args : array() );
	}
}
