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); + } }