Skip to content

Commit 83e9f6d

Browse files
feat: make Encoding class implement Countable
1 parent 7ade08b commit 83e9f6d

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"config": {
4545
"sort-packages": true,
4646
"allow-plugins": {
47+
"codewithkyrian/platform-package-installer": true,
4748
"pestphp/pest-plugin": true,
4849
"php-http/discovery": true
4950
}

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)