protected function encodeString($value, $length = -1) {
        if (-1 !== $length && $length < strlen($value)) {
            throw new TooLongDataException($value, $length);
        }
        return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\"";
    }
protected function encodeString($value, $length = -1) {
        if (-1 !== $length && $length < strlen($value)) {
            throw new TooLongDataException($value, $length);
        }
        return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\"";
    }
protected function encodeString ( $ value , $ length = - 1 ) { if ( - 1 !== $ length && $ length < strlen ( $ value ) ) { throw new TooLongDataException ( $ value , $ length ) ; } return "\"" . substr ( $ value , 0 , ( - 1 === $ length ? strlen ( $ value ) : $ length ) ) . "\"" ; }
Encode a string value.

@param string $value The value.
@param int $length The length.
@return string Returns the encoded string.
@throws TooLongDataException Throws a too long data exception if the value exceeds the length.
Encode a string value .