public function setContentData($data) { $this->contentData = $data; $this->contentLength = strlen($this->contentData); $extraLength = $this->contentLength % 8; $this->paddingLength = $extraLength ? 8 - $extraLength : 0; }
/** * Padding size should resize the packet size to the 8 bytes boundary for optimal performance */ public function testAutomaticCalculationOfPaddingLength() { $record = new Record(); $record->setContentData('12345'); $this->assertEquals($record->getPaddingLength(), 3); $record->setContentData('12345678'); $this->assertEquals($record->getPaddingLength(), 0); }