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/Constant.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Constant.php (limited to 'src/Constant.php') diff --git a/src/Constant.php b/src/Constant.php new file mode 100644 index 0000000..6cd63a7 --- /dev/null +++ b/src/Constant.php @@ -0,0 +1,36 @@ +value < 0) { + throw new \InvalidArgumentException('Field value must be non-negative.'); + } + + if ($this->value > $this->maxValue()) { + throw new \InvalidArgumentException(sprintf( + 'Field value %d exceeds maximum %d for %d bits.', + $this->value, + $this->maxValue(), + $this->bits + )); + } + } + + public function value(): int + { + return $this->value; + } +} -- cgit v1.2.3