public function encode($value)
    {
        switch (true) {
            case is_null($value):
                return $this->encodeString('', self::T_NULL);
            case is_bool($value):
                return $this->encodeString($value ? 'true' : 'false', self::T_BOOL);
            case is_int($value):
                return $this->encodeString($value, self::T_INT);
            case is_float($value):
                return $this->encodeString($value, self::T_FLOAT);
            case is_array($value):
                return $this->encodePHPArray($value);

            case is_resource($value):
                throw new InvalidArgumentException("You can't encode a PHP resource as a tagged netstring.");

            default:
                return $this->encodeString($value);
        }
    }
public function encode($value)
    {
        switch (true) {
            case is_null($value):
                return $this->encodeString('', self::T_NULL);
            case is_bool($value):
                return $this->encodeString($value ? 'true' : 'false', self::T_BOOL);
            case is_int($value):
                return $this->encodeString($value, self::T_INT);
            case is_float($value):
                return $this->encodeString($value, self::T_FLOAT);
            case is_array($value):
                return $this->encodePHPArray($value);

            case is_resource($value):
                throw new InvalidArgumentException("You can't encode a PHP resource as a tagged netstring.");

            default:
                return $this->encodeString($value);
        }
    }
public function encode ( $ value ) { switch ( true ) { case is_null ( $ value ) : return $ this -> encodeString ( '' , self :: T_NULL ) ; case is_bool ( $ value ) : return $ this -> encodeString ( $ value ? 'true' : 'false' , self :: T_BOOL ) ; case is_int ( $ value ) : return $ this -> encodeString ( $ value , self :: T_INT ) ; case is_float ( $ value ) : return $ this -> encodeString ( $ value , self :: T_FLOAT ) ; case is_array ( $ value ) : return $ this -> encodePHPArray ( $ value ) ; case is_resource ( $ value ) : throw new InvalidArgumentException ( "You can't encode a PHP resource as a tagged netstring." ) ; default : return $ this -> encodeString ( $ value ) ; } }
Encodes the value as a tagged netstring.

@see TNetstring_Encoder#encode

@param mixed $value
@return string
@throws InvalidArgumentException If the value can't be converted to a
string, e.g. the value is a resource
Encodes the value as a tagged netstring .