public function setData($data, $encoding = self::ENCODING_URL_ENCODED_OCTETS)
    {
        switch ($encoding) {
            case self::ENCODING_URL_ENCODED_OCTETS:
                $this->encoding = self::ENCODING_URL_ENCODED_OCTETS;
                $this->encodedData = rawurlencode($data);
                break;
            case self::ENCODING_BASE64:
                $this->encoding = self::ENCODING_BASE64;
                $this->encodedData = base64_encode($data);
                break;
            default:
                throw new \InvalidArgumentException('Unsupported encoding scheme');
                break;
        }
    }
public function setData($data, $encoding = self::ENCODING_URL_ENCODED_OCTETS)
    {
        switch ($encoding) {
            case self::ENCODING_URL_ENCODED_OCTETS:
                $this->encoding = self::ENCODING_URL_ENCODED_OCTETS;
                $this->encodedData = rawurlencode($data);
                break;
            case self::ENCODING_BASE64:
                $this->encoding = self::ENCODING_BASE64;
                $this->encodedData = base64_encode($data);
                break;
            default:
                throw new \InvalidArgumentException('Unsupported encoding scheme');
                break;
        }
    }
public function setData ( $ data , $ encoding = self :: ENCODING_URL_ENCODED_OCTETS ) { switch ( $ encoding ) { case self :: ENCODING_URL_ENCODED_OCTETS : $ this -> encoding = self :: ENCODING_URL_ENCODED_OCTETS ; $ this -> encodedData = rawurlencode ( $ data ) ; break ; case self :: ENCODING_BASE64 : $ this -> encoding = self :: ENCODING_BASE64 ; $ this -> encodedData = base64_encode ( $ data ) ; break ; default : throw new \ InvalidArgumentException ( 'Unsupported encoding scheme' ) ; break ; } }
Sets the data for the data URI, which it stores in encoded form using
the encoding scheme provided.

@param string $data     Data to encode then store
@param int    $encoding Class constant of either
{@link DataUri::ENCODING_URL_ENCODED_OCTETS} or
{@link DataUri::ENCODING_BASE64}

@throws InvalidArgumentException
Sets the data for the data URI which it stores in encoded form using the encoding scheme provided .