Skip to content

Commit

Permalink
Extract byte count calculation to a method
Browse files Browse the repository at this point in the history
  • Loading branch information
olafkryus committed Apr 4, 2020
1 parent 0baaf70 commit 15e34a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/DataType/BinaryValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ public function isSigned(): bool
return $this->signed;
}

/**
* @return int
*/
public function getByteCount(): int
{
return count($this->value);
}

/**
* @return int
*/
public function toInt(): int
{
$value = 0;
$byteCount = count($this->value);
$byteCount = $this->getByteCount();

if ($this->endianness === self::ENDIANNESS_BIG_ENDIAN) {
for ($i = 0; $i < $byteCount; ++$i) {
Expand Down

0 comments on commit 15e34a8

Please sign in to comment.