src/Xdr/XdrEncoder.php
private static function applyPadding($value, $targetLength = 4, $rightPadding = true)
    {
        // No padding necessary if it's a multiple of 4 bytes
        if (strlen($value) % $targetLength === 0) return $value;

        $numPaddingChars = $targetLength - (strlen($value) % $targetLength);

        if ($rightPadding) {
            return $value . str_repeat(chr(0), $numPaddingChars);
        }
        else {
            return str_repeat(chr(0), $numPaddingChars) . $value;
        }
    }
private static function applyPadding($value, $targetLength = 4, $rightPadding = true)
    {
        // No padding necessary if it's a multiple of 4 bytes
        if (strlen($value) % $targetLength === 0) return $value;

        $numPaddingChars = $targetLength - (strlen($value) % $targetLength);

        if ($rightPadding) {
            return $value . str_repeat(chr(0), $numPaddingChars);
        }
        else {
            return str_repeat(chr(0), $numPaddingChars) . $value;
        }
    }
Ensures $value's length is a multiple of $targetLength bytes

The default value for XDR is 4

@param $value
@param $targetLength - desired length after padding is applied
@param $rightPadding - pad on the right of the value, false to pad to the left
@return string