This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
9
{
10
/**
11
* @param \PhpBinaryReader\BinaryReader $br
12
* @param int $length
13
* @return string
14
* @throws \OutOfBoundsException
15
* @throws InvalidDataException
16
*/
17
16
public function read(BinaryReader &$br, $length)
18
{
19
16
if (!is_int($length)) {
20
4
throw new InvalidDataException('The length parameter must be an integer');
21
}
22
23
12
if (!$br->canReadBytes($length)) {
24
4
throw new \OutOfBoundsException('Cannot read string, it exceeds the boundary of the file');
25
}
26
27
8
$str = $br->readFromHandle($length);
28
29
8
return $str;
30
}
31
32
/**
33
* @param \PhpBinaryReader\BinaryReader $br
34
* @param int $length
35
* @return string
36
*/
37
4
public function readAligned(BinaryReader &$br, $length)
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.