public function maskPayload($maskingKey = null) {
        if (null === $maskingKey) {
            $maskingKey = $this->generateMaskingKey();
        }

        if (static::MASK_LENGTH !== strlen($maskingKey)) {
            throw new \InvalidArgumentException("Masking key must be " . static::MASK_LENGTH ." characters");
        }

        if (extension_loaded('mbstring') && true !== mb_check_encoding($maskingKey, 'US-ASCII')) {
            throw new \OutOfBoundsException("Masking key MUST be ASCII");
        }

        $this->unMaskPayload();

        $this->secondByte = $this->secondByte | 128;
        $this->data[1]    = chr($this->secondByte);

        $this->data = substr_replace($this->data, $maskingKey, $this->getNumPayloadBytes() + 1, 0);

        $this->bytesRecvd += static::MASK_LENGTH;
        $this->data        = substr_replace($this->data, $this->applyMask($maskingKey), $this->getPayloadStartingByte(), $this->getPayloadLength());

        return $this;
    }
public function maskPayload($maskingKey = null) {
        if (null === $maskingKey) {
            $maskingKey = $this->generateMaskingKey();
        }

        if (static::MASK_LENGTH !== strlen($maskingKey)) {
            throw new \InvalidArgumentException("Masking key must be " . static::MASK_LENGTH ." characters");
        }

        if (extension_loaded('mbstring') && true !== mb_check_encoding($maskingKey, 'US-ASCII')) {
            throw new \OutOfBoundsException("Masking key MUST be ASCII");
        }

        $this->unMaskPayload();

        $this->secondByte = $this->secondByte | 128;
        $this->data[1]    = chr($this->secondByte);

        $this->data = substr_replace($this->data, $maskingKey, $this->getNumPayloadBytes() + 1, 0);

        $this->bytesRecvd += static::MASK_LENGTH;
        $this->data        = substr_replace($this->data, $this->applyMask($maskingKey), $this->getPayloadStartingByte(), $this->getPayloadLength());

        return $this;
    }
public function maskPayload ( $ maskingKey = null ) { if ( null === $ maskingKey ) { $ maskingKey = $ this -> generateMaskingKey ( ) ; } if ( static :: MASK_LENGTH !== strlen ( $ maskingKey ) ) { throw new \ InvalidArgumentException ( "Masking key must be " . static :: MASK_LENGTH . " characters" ) ; } if ( extension_loaded ( 'mbstring' ) && true !== mb_check_encoding ( $ maskingKey , 'US-ASCII' ) ) { throw new \ OutOfBoundsException ( "Masking key MUST be ASCII" ) ; } $ this -> unMaskPayload ( ) ; $ this -> secondByte = $ this -> secondByte | 128 ; $ this -> data [ 1 ] = chr ( $ this -> secondByte ) ; $ this -> data = substr_replace ( $ this -> data , $ maskingKey , $ this -> getNumPayloadBytes ( ) + 1 , 0 ) ; $ this -> bytesRecvd += static :: MASK_LENGTH ; $ this -> data = substr_replace ( $ this -> data , $ this -> applyMask ( $ maskingKey ) , $ this -> getPayloadStartingByte ( ) , $ this -> getPayloadLength ( ) ) ; return $ this ; }
Apply a mask to the payload
@param string|null If NULL is passed a masking key will be generated
@throws \OutOfBoundsException
@throws \InvalidArgumentException If there is an issue with the given masking key
@return Frame
Apply a mask to the payload