protected function encode($val) {
		switch (true) {
			case is_array($val):
				return self::T_ARRAY . json_encode($val);
			case is_int($val):
				return self::T_INT . $val;
			case is_bool($val):
				return self::T_BOOLEAN . $val;
			case is_float($val):
				return self::T_DOUBLE . $val;
			case is_object($val):
				return self::T_OBJECT . serialize($val);
			default:
				return self::T_STRING . $val;
		}
	}