From a49763dd739c3c68c4a8322896d594e926ac8e6b Mon Sep 17 00:00:00 2001 From: Zhineng Li Date: Mon, 5 Jan 2026 16:26:11 +0800 Subject: first commit --- src/Field.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/Field.php (limited to 'src/Field.php') diff --git a/src/Field.php b/src/Field.php new file mode 100644 index 0000000..9e11bad --- /dev/null +++ b/src/Field.php @@ -0,0 +1,58 @@ + 63) { + throw new \InvalidArgumentException('Bits must be between 1 and 63.'); + } + } + + /** + * The bit size. + */ + public function bits(): int + { + return $this->bits; + } + + /** + * The maximum value based on the number of bits. + */ + public function maxValue(): int + { + return (1 << $this->bits) - 1; + } + + /** + * Set the bit offset. + */ + public function setOffset(int $offset): static + { + $this->offset = $offset; + + return $this; + } + + /** + * The bit offset. + */ + public function offset(): int + { + return $this->offset; + } + + abstract public function value(): int; +} -- cgit v1.2.3