MCPcopy Create free account
hub / github.com/apache/avro / AvroStringIO

Class AvroStringIO

lang/php/lib/IO/AvroStringIO.php:29–252  ·  view source on GitHub ↗

* AvroIO wrapper for string access * @package Avro */

Source from the content-addressed store, hash-verified

27 * @package Avro
28 */
29class AvroStringIO extends AvroIO
30{
31 /**
32 * @var string
33 */
34 private $string_buffer;
35 /**
36 * @var int current position in string
37 */
38 private $current_index;
39 /**
40 * @var boolean whether or not the string is closed.
41 */
42 private $is_closed;
43
44 /**
45 * @param string $str initial value of AvroStringIO buffer. Regardless
46 * of the initial value, the pointer is set to the
47 * beginning of the buffer.
48 * @throws AvroIOException if a non-string value is passed as $str
49 */
50 public function __construct($str = '')
51 {
52 $this->is_closed = false;
53 $this->string_buffer = '';
54 $this->current_index = 0;
55
56 if (is_string($str)) {
57 $this->string_buffer .= $str;
58 } else {
59 throw new AvroIOException(
60 sprintf('constructor argument must be a string: %s', gettype($str))
61 );
62 }
63 }
64
65 /**
66 * Append bytes to this buffer.
67 * (Nothing more is needed to support Avro.)
68 * @param string $arg bytes to write
69 * @returns int count of bytes written.
70 * @throws AvroIOException if $args is not a string value.
71 */
72 public function write($arg)
73 {
74 $this->checkClosed();
75 if (is_string($arg)) {
76 return $this->appendStr($arg);
77 }
78 throw new AvroIOException(
79 sprintf(
80 'write argument must be a string: (%s) %s',
81 gettype($arg),
82 var_export($arg, true)
83 )
84 );
85 }
86

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…