tiny-blocks/encoder
最新稳定版本:3.1.0
Composer 安装命令:
composer require tiny-blocks/encoder
包简介
Encoder and decoder for arbitrary data.
README 文档
README
Overview
Encoder and decoder for arbitrary data.
Installation
composer require tiny-blocks/encoder
How to use
The library provides concrete implementations of the Encoder interface, enabling encoding and decoding of data into
specific formats like Base62.
Using Base62
To encode a value into Base62 format:
$encoder = Base62::from(value: 'Hello world!'); $encoded = $encoder->encode(); # Output: T8dgcjRGuYUueWht
To decode a Base62-encoded value back to its original form:
$encoder = Base62::from(value: 'T8dgcjRGuYUueWht'); $decoded = $encoder->decode(); # Output: Hello world!
If you attempt to decode an invalid Base62 value, an InvalidDecoding exception will be thrown:
try { $encoder = Base62::from(value: 'invalid_value'); $decoded = $encoder->decode(); } catch (InvalidDecoding $exception) { echo $exception->getMessage(); # Output: The value <invalid_value> could not be decoded. }
License
Encoder is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.
统计信息
- 总下载量: 67.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-06