Exemplo n.º 1
0
 /**
  * Returns an variable number of bytes
  *
  * @param  \PhpBinaryReader\BinaryReader $br
  * @param  int|null                      $length
  * @return string
  * @throws \OutOfBoundsException
  * @throws InvalidDataException
  */
 public function read(BinaryReader &$br, $length = null)
 {
     if (!is_int($length)) {
         throw new InvalidDataException('The length parameter must be an integer');
     }
     $br->align();
     if (!$br->canReadBytes($length)) {
         throw new \OutOfBoundsException('Cannot read bytes, it exceeds the boundary of the file');
     }
     $segment = $br->readFromHandle($length);
     return $segment;
 }
Exemplo n.º 2
0
 /**
  * @param  \PhpBinaryReader\BinaryReader $br
  * @param  int                           $length
  * @return string
  */
 public function readAligned(BinaryReader &$br, $length)
 {
     $br->align();
     return $this->read($br, $length);
 }