PHPackages                             nanoblocktech/shipping-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nanoblocktech/shipping-calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nanoblocktech/shipping-calculator
=================================

PHP class to determines shipping fee based on origin latitude and lonitude of customer from business location.

1.4(2y ago)036MITPHPPHP ^7.0 || ^8.0

Since Nov 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/nanoblocktech/shipping-calculator)[ Packagist](https://packagist.org/packages/nanoblocktech/shipping-calculator)[ RSS](/packages/nanoblocktech-shipping-calculator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

Class Shipping Calculator
-------------------------

[](#class-shipping-calculator)

Determines the shipping fee based on the customer's longitude and latitude to the business location.

### Functions

[](#functions)

- Calculates the distance between business and customer locations
- Determines the shipping fee based on the provided charge per distance.
- Determines the estimated traveling time based on distance and speed

Installation Guide via Composer:

```
composer require nanoblocktech/shipping-calculator
```

### Usages

[](#usages)

```
use Luminova\ExtraUtils\ShippingCalculator;

$calculator = new ShippingCalculator();

// Set business and customer locations

$calculator->setOrigin(6.47427, 7.56196); // Business location (Enugu Airport Nigeria)
$calculator->setDestination(6.51181, 7.35535); // Customer location (Udi Nigeria)
$calculator->setCharge(100); // Initial shipping cost per distance km, or ml

// Calculate distance and return new ShippingDistance instance class

$distance = $calculator->getDistance();

// Get the estimated time information

$time = $calculator->getTime();

// Get your calculated information

echo "Distance: $distance->toDistance() \n";
echo "Distance[km|ml]: $distance->toString() \n";
echo "Shipping Fee: $distance->getCurrency(2)\n";
echo "Shipping Fee: $distance->getCharges()\n";
```

### Methods

[](#methods)

#### ShippingCalculator

[](#shippingcalculator)

Setting up your calculations `$calculator = new ShippingCalculator(ShippingCalculator::KM);`

Methods And ParamDescriptionssetOrigin(float latitude, float longitude): selfSet the origin location latitude and longitudesetDestination(float latitude, float longitude): selfSet the destination location latitude and longitudesetCharge(float amount): selfSet initial shipping charge per calculation distancesetSpeed(int speed): selfSet speed in units per hour, to calculate estimated time.getDistance(): ShippingDistanceCalculate the distance between the origin/destination and return distance instance.#### ShippingDistance

[](#shippingdistance)

The method which `$distance = $calculator->getDistance();` is returned

Methods And ParamDescriptionstoDistance(): floatGet the calculated distance between the origin and destination latitude and longitude.toString(): stringGet the distance as a string (e.g., '10km').toCurrency(int decimals = 2, string symbol): stringConvert the distance to currency format with optional currency symbol and decimal places.toMile(): floatConvert the distance from kilometer to miles.toKilometer(): floatConvert the distance from miles to kilometers.getCurrency(int decimal = 2): stringGet the calculated currency value based on the distance and initial amount.getCharges(): floatGet the calculated chargesgetTime(): ShippingTimeGet distance time instance#### ShippingTime

[](#shippingtime)

The method which `$time = $distance->getTime();` is returned

Methods And ParamDescriptionstoTime(): floatGet the calculated time required to cover the distance.toHours(): intConvert the total time to hours.toSeconds(): intGet the total time in seconds.toMinutes(): intConvert the total time to minutes.toDays(): intConvert the total time to days.toString(): stringGet a formatted string representation of the total time.toObject(): objectGet an object representation of the total time.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

901d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce34af529a4ed50696211a2b4d330fbadd2d1738bc5d010523eb4a85cf342b17?d=identicon)[peterujah](/maintainers/peterujah)

---

Top Contributors

[![peterujah](https://avatars.githubusercontent.com/u/16369609?v=4)](https://github.com/peterujah "peterujah (23 commits)")

---

Tags

distance-calculatorgpsphpphp-shipping-classshipping-calculatorshipping-distancephpluminovadistance calculationshipping calculation

### Embed Badge

![Health badge](/badges/nanoblocktech-shipping-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/nanoblocktech-shipping-calculator/health.svg)](https://phpackages.com/packages/nanoblocktech-shipping-calculator)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
