Skip to content

Commit 3957912

Browse files
committed
(wip|[skip ci]): Integrate TextString encoding into CBOR class
- Add support for encoding string data using the `TextString` class within the `CBOR::encode` method. - Update the CBOR class to handle the `string` type by delegating encoding to `TextString::encode`. - Keep the `decode` method as a placeholder for future implementation.
1 parent a2dc3ab commit 3957912

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/CBOR/CBOR.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace ATProto\Core\CBOR;
1313

14+
use ATProto\Core\CBOR\MajorTypes\TextString;
1415
use ATProto\Core\CBOR\MajorTypes\UnsignedInteger;
1516

1617
class CBOR
@@ -21,13 +22,16 @@ public static function encode(string|int|array $data): string
2122
case 'integer':
2223
return UnsignedInteger::encode($data);
2324
break;
25+
case 'string':
26+
return TextString::encode($data);
27+
break;
2428
}
2529

2630
throw new \ValueError("Unsupported type: " . gettype($data));
2731
}
2832

2933
public static function decode(string $data): int
3034
{
31-
return UnsignedInteger::decode((string) $data);
35+
// TODO
3236
}
3337
}

0 commit comments

Comments
 (0)