From 15e34a81d4324c34b112c8a57dbf455aa3d83489 Mon Sep 17 00:00:00 2001 From: olafkry208 Date: Sat, 4 Apr 2020 12:37:13 +0200 Subject: [PATCH] Extract byte count calculation to a method --- src/DataType/BinaryValue.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/DataType/BinaryValue.php b/src/DataType/BinaryValue.php index 4488f55..33dbb83 100644 --- a/src/DataType/BinaryValue.php +++ b/src/DataType/BinaryValue.php @@ -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) {