function it_generates_a_packet_with_correct_offset(Chunk $chunk) { $this->beConstructedWith(8); $chunk->getField()->willReturn('otherfield'); $chunk->getValue()->willReturn('more and more data'); $packet = new Packet(19, 10, 18, 8); $this->fromChunk($chunk, 19)->shouldBeLike($packet); }
public function fromChunk(Chunk $chunk, $start = 0) { $fieldLength = strlen($chunk->getField()); $valueLength = strlen($chunk->getValue()); return new DataPacket($start, $fieldLength, $valueLength, $this->getBufferSize()); }