Exemplo n.º 1
0
 /**
  * @param string $header
  *
  * @throws InvalidArgumentException thrown when $header is not a string
  * @throws LengthException thrown when $header is not exactly 8 bytes
  * @return Header
  */
 public static function decode($header)
 {
     if (!is_string($header)) {
         throw new InvalidArgumentException(sprintf('Header must be a (binary) string, %s given', gettype($header)));
     }
     if (strlen($header) != 8) {
         throw new LengthException(sprintf('Header must be exactly 8 bytes, %d bytes given', strlen($header)));
     }
     $header = \unpack('Cversion/Ctype/nrequestId/nlength/CpaddingLength/Creserved', $header);
     return new self(RecordType::instance($header['type']), $header['requestId'], $header['length'], $header['paddingLength']);
 }
Exemplo n.º 2
0
 /**
  * @covers ::maxtype
  */
 public function testDirectInstancationMethodOfMaxtype()
 {
     $expectedRecordType = RecordType::instance(RecordType::MAXTYPE);
     $recordType = RecordType::maxtype();
     self::assertSame($expectedRecordType, $recordType);
 }