/** * @since 1.0 * @uses getChunkClass() * @uses formatOffset() * @uses Delta::toBinary() * @uses Util::binaryToHex() * @uses Event::toBinary() * @uses Event::getLength() * @uses Delta::getLength() * * @param Event $event * @return string */ public function beforeEvent(Event $event) { if ($this->delta === null) { return ''; } $class = $this->getChunkClass($event); $text = "<tr class=\"{$class}\">" . $this->formatOffset($this->offset); // -- all of this goofy looking math just formats everything prettily -- // $deltaHex = Util::binaryToHex($this->delta->toBinary()); $delta = '<span class="delta">' . wordwrap(implode(' ', $deltaHex), 23, '<br />') . '</span>'; $eventHex = Util::binaryToHex($event->toBinary()); $lineLength = 23 - strlen(implode(' ', $deltaHex)) % 23; $eventSegment = wordwrap(implode(' ', $eventHex), $lineLength, '|'); $bar = strpos($eventSegment, '|'); if ($bar !== false) { $eventSegment = substr($eventSegment, 0, $bar) . '<br />' . wordwrap(substr($eventSegment, $bar + 1), 23, '<br />'); } // -- end goofiness -- // $text .= '<td><tt>' . $delta . ' ' . $eventSegment . '</tt></td>'; $this->offset += $event->getLength() + $this->delta->getLength(); return $text; }
public function testGetLength() { $this->assertSame(2, $this->obj->getLength()); }