定制 anderswelt/stringtotype 二次开发

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

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

anderswelt/stringtotype

最新稳定版本:1.0

Composer 安装命令:

composer require anderswelt/stringtotype

包简介

A php service to convert string content to its inherent type

README 文档

README

A small high performance service to convert a string to its basic type based on the string contents

Installation

Composer:

composer require anderswelt/stringtotype

Usage

<?php

use StringToType\StringToType


$stringWhichisReallyFloat = "123.123";
$stringWhichisReallyInt = "123";
$stringWhichisReallyBool = "true";
$stringWhichLooksLikeButIsntFloat = "0123.23";

$float = StringToType::convert($stringWhichisReallyFloat);
$int = StringToType::convert($stringWhichisReallyInt);
$bool = StringToType::convert($stringWhichisReallyBool);
$string = StringToType::convert($stringWhichLooksLikeButIsntFloat);

The tests give a hint as how it interprets what kind of string to which type.

About

Searched around to find a robust and high performance solution to this problem. Found nothing that was close, so I've created this one. It's also faster than most regex based versions floating around on stackoverflow.

Requirements

Due to typed parameters being used it needs PHP 7.4 and later.

Author

Johannes Rebhan der.waldgeist@gmail.com http://waldgeist.org

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-06