承接 soleimanpour/toolkit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

soleimanpour/toolkit

最新稳定版本:v1.0.1

Composer 安装命令:

composer require soleimanpour/toolkit

包简介

Custom Package

README 文档

README

Version: v1.0.1

Soleimanpour/Toolkit

This package provides utility functions for generating short URLs and converting numbers to different bases (up to base 62). It is particularly useful for URL shortening and ID generation.

Features

  • generate_short_url($input): This function generates a short unique string based on the input.

  • to_base($number, $base): This function converts a given number to a specified base, with support for up to base 62.

  • custom_string_to_int(string $input): Converts a string to a numeric hash while preserving the order of characters. Uses a rolling hash algorithm with modulus to prevent overflows.

Installation

You can install the package via Composer:

composer require soleimanpour/toolkit

Usage

Example 1: Generating a short URL

echo generate_short_url('abc');  // Example output: p46

echo generate_short_url('cba');  // Example output: pz4

echo generate_short_url('aaaaaaaaaa');  // Example output: tXt6X

Example 2: Converting a number to base 62

echo to_base(123456, 62);  // Example output: w7e

Example 3: Converting a string to an integer hash

echo custom_string_to_int('abc');        // Example output: 96354

echo custom_string_to_int('cba');        // Example output: 98274

echo custom_string_to_int('aaaaaaaaaa'); // Example output: 442687003

License

This package is open-source software licensed under the MIT license.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-07