fabyo0/weight-conversion
最新稳定版本:v1.1.0
Composer 安装命令:
composer require fabyo0/weight-conversion
包简介
A simple and flexible weight conversion package for PHP
README 文档
README
A simple and flexible weight conversion package for PHP. Convert between kilograms, grams, pounds, ounces and more with ease.
Note: This package was developed as a learning project, following the Spatie Laravel Package Training course as a reference.
Installation
You can install the package via composer:
composer require fabyo0/weight-conversion
Usage
use Fabyo0\WeightConversion\WeightConversion; // Static factory methods $weight = WeightConversion::fromKilograms(100); $weight = WeightConversion::fromPounds(220); // Method chaining $total = WeightConversion::fromKilograms(50) ->add(25, 'kg') ->subtract(10, 'lb') ->toKilograms(); // Comparison methods $weight1 = WeightConversion::fromKilograms(100); $weight2 = WeightConversion::fromPounds(220); $weight1->isGreaterThan($weight2); // true/false // Formatting output $weight = new WeightConversion(75.5, 'kg'); echo $weight->format(2); // "75.50 kg" // Get supported units WeightConversion::getSupportedUnits(); // ['kg', 'g', 'mg', 'lb', 'oz', 't']
Supported Units
| Unit | Symbol |
|---|---|
| Kilogram | kg |
| Gram | g |
| Milligram | mg |
| Pound | lb |
| Ounce | oz |
| Ton (Metric) | t |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Security Vulnerabilities
If you discover a security vulnerability, please send an email to emredikmen002@gmail.com.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-22