Kafka\Protocol\Encoder::encodeArray PHP Method

encodeArray() public static method

encode key array
public static encodeArray ( array $array, Callable $func, null $options = null ) : string
$array array
$func Callable
$options null
return string
    public static function encodeArray(array $array, $func, $options = null)
    {
        if (!is_callable($func, false)) {
            throw new \Kafka\Exception\Protocol('Encode array failed, given function is not callable.');
        }
        $arrayCount = count($array);
        $body = '';
        foreach ($array as $value) {
            if (!is_null($options)) {
                $body .= call_user_func($func, $value, $options);
            } else {
                $body .= call_user_func($func, $value);
            }
        }
        return self::pack(self::BIT_B32, $arrayCount) . $body;
    }