Skip to content

Commit 5be81e0

Browse files
feat: make Encoding class implement Countable
1 parent 7ade08b commit 5be81e0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Encoding.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Represents the output of tokenization.
99
*/
10-
readonly class Encoding
10+
readonly class Encoding implements \Countable
1111
{
1212
/**
1313
* @param int[] $ids The list of token IDs
@@ -19,4 +19,9 @@ public function __construct(
1919
public array $tokens,
2020
public array $typeIds = [],
2121
) {}
22+
23+
public function count(): int
24+
{
25+
return \count($this->ids);
26+
}
2227
}

0 commit comments

Comments
 (0)