public function test_string_rep() { $writers_schema_json = '"null"'; $writers_schema = AvroSchema::parse($writers_schema_json); $datum_writer = new AvroIODatumWriter($writers_schema); $strio = new AvroStringIO(); $this->assertEquals('', $strio->string()); $dw = new AvroDataIOWriter($strio, $datum_writer, $writers_schema_json); $dw->close(); $this->assertEquals(57, strlen($strio->string()), AvroDebug::ascii_string($strio->string())); $read_strio = new AvroStringIO($strio->string()); $datum_reader = new AvroIODatumReader(); $dr = new AvroDataIOReader($read_strio, $datum_reader); $read_data = $dr->data(); $datum_count = count($read_data); $this->assertEquals(0, $datum_count); }
/** * Determines the endianness of the host platform and memoizes * the result to Avro::$endianness. * * Based on a similar check perfomed in http://pear.php.net/package/Math_BinaryUtils * * @throws AvroException if the endianness cannot be determined. */ private static function set_endianness() { $packed = pack('d', 1); switch ($packed) { case "?ð": self::$endianness = self::BIG_ENDIAN; break; case "ð?": self::$endianness = self::LITTLE_ENDIAN; break; default: throw new AvroException(sprintf('Error determining platform endianness: %s', AvroDebug::hex_string($packed))); } }