Skip to content
/ libms Public

PHP extension with various custom classes/functions

Notifications You must be signed in to change notification settings

mbswe/libms

Repository files navigation

Classes and Methods

MSMath

A class that contains mathematical utility functions.

  • clamp: Constrain (or clamp) a numeric value between two bounds.

    MSMath::clamp(mixed $value, mixed $min, mixed $max): int|float
  • lerp: Linearly interpolate between two values.

    MSMath::lerp(float $start, float $end, float $t): float
  • inverseLerp: Calculate the inverse linear interpolation of a value between two bounds.

    MSMath::inverseLerp(float $start, float $end, float $value): float
  • remapRange: Remap a value from one range to another.

    MSMath::remapRange(float $value, float $oldMin, float $oldMax, float $newMin, float $newMax): float
  • mean: Calculate the mean of an array of numbers.

    MSMath::mean(array $values): float

MSGeoHash

A class that contains geohash utility functions.

  • encode: Encode a latitude and longitude into a geohash string.

    MSGeoHash::encode(float $latitude, float $longitude, int $precision = 12): string
  • decode: Decode a geohash string into a latitude and longitude.

    MSGeoHash::decode(string $hash): array
  • distance: Calculate the distance between two geohash strings. Returns the distance in kilometers.

    MSGeoHash::distance(string $hash1, string $hash2): float
  • neighbor: Calculate the neighbor of a geohash string in a given direction (N, S, E, W, NW...).

    MSGeoHash::neighbor(string $hash, string $direction): string
  • neighbors: Calculate the neighbors of a geohash string in all directions (N, S, E, W, NW...).

    MSGeoHash::neighbors(string $hash): array

MSMisc

A class that contains miscellaneous functionality.

  • toExcelColumn: Convert a number to an Excel column name.

    MSMisc::toExcelColumn(int $number): string
  • fromExcelColumn: Convert an Excel column name to a number.

    MSMisc::fromExcelColumn(string $column): int

Testing the extension in docker

  1. Build the extension:
    docker-compose -f docker-compose.build.yml up --build
  2. Start nginx/php:
    docker-compose -f docker-compose.runtime.yml up --build
  3. Access the extension:
    • Open your browser and navigate to http://localhost:8080/
    • Edit www/index.php to make changes.

About

PHP extension with various custom classes/functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published