定制 fabyo0/weight-conversion 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fabyo0/weight-conversion

最新稳定版本:v1.1.0

Composer 安装命令:

composer require fabyo0/weight-conversion

包简介

A simple and flexible weight conversion package for PHP

README 文档

README

Latest Version on Packagist Tests Total Downloads

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固