From de1a6cd7c2250c191ef4691ad7de2d22803345ae Mon Sep 17 00:00:00 2001 From: Kyrian Obikwelu Date: Fri, 6 Feb 2026 11:22:53 +0100 Subject: [PATCH] feat: make Encoding class implement Countable --- src/Encoding.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Encoding.php b/src/Encoding.php index 523bc9d..6689d4e 100644 --- a/src/Encoding.php +++ b/src/Encoding.php @@ -7,7 +7,7 @@ /** * Represents the output of tokenization. */ -readonly class Encoding +readonly class Encoding implements \Countable { /** * @param int[] $ids The list of token IDs @@ -19,4 +19,9 @@ public function __construct( public array $tokens, public array $typeIds = [], ) {} + + public function count(): int + { + return \count($this->ids); + } }