定制 nekland/tools 二次开发

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

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

nekland/tools

Composer 安装命令:

composer require nekland/tools

包简介

Just some tools to work better with PHP

README 文档

README

Build Status

Just some classes helping to code with PHP in general. No dependencies. High quality code.

This repository follows semver.

Installation

composer require "nekland/tools"

Reference

This library provide some tools to help you with your developments.

Here is the list of tools it provides:

StringTools class

Encoding arguments are optionals.

::camelize

StringTools::camelize($str, $from, $encoding, $normalize = true) : string
  • $str string input
  • $from (optional, default "_") input string format (can be "-" or "_")
  • $encoding (optional, default "UTF-8") encoding of your input string
  • $normalize decide either you want to normalize (remove special characters) or not, that's what you want in most cases when camelizing

::startsWith

Say if the given string starts with needle or not.

StringTools::startsWith($str, $start) : bool
  • $str string input
  • $start string it should starts with

::endsWith

Say if the given string ends with needle or not.

StringTools::endsWith($str, $end) : bool
  • $str string input
  • $end string it should ends with

::removeStart

Removes the start of the string if it matches with the given one.

StringTools::removeStart($str, $toRemove) : string
  • $str string input
  • $toRemove string to remove at the start of $str

::removeEnd

Removes the end of the string if it matches with the given text to remove.

StringTools::removeEnd($str, $toRemove) : string
  • $str string input
  • $toRemove string to remove at the end of $str

::contains

StringTools::contains($str, $needle) : bool
  • $str string input
  • $needle potentially contained string

::mb_ucfirst

Adds missing multi-byte PHP function for ucfirst standard function.

StringTools::mb_ucfirst($str, $encoding) : string
  • $str string input
  • $encoding (optional, default "UTF-8") encoding of your input string

ArrayTools class

::removeValue

ArrayTools::removeValue($array, $value) : void
  • $array input array passed by reference
  • $value The value to remove from the $array

EqualableInterface

Helps you equals on objects on a similar way as java.

equals

Method that you must implements to check if the object taking as parameter is equals or not.

DateTimeComparator class

For following methods lowest and greatest, you can provide unlimited DateTimeInterface objects. Please note that non DateTimeInterface objects will be ignored by functions.

::greatest

Compare \DateTimeInterface from parameters and return the greatest

DateTimeComparator::greatest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface

::lowest

Compare \DateTimeInterface from parameters and return the lowest

DateTimeComparator::lowest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface

Temporary file management

The class TemporaryFile helps you to create temporary file with ease.

::__construct()

TemporaryFile::__construct(TemporaryDirectory $dir = null, string $prefix = '')

Examples:

// Create a file in temporary folder
$file = new TemporaryFile();

// Create a file inside a temporary directory (see TemporaryDirectory class)
$file = new TemporaryFile($temporaryDir);

// Create a file in a temporary folder with php_ prefix.
$file = new TemporaryFile(null, 'php_');

::setContent & ::getContent

TemporaryFile::setContent(string $content)
TemporaryFile::getContent(): string

::getPathname()

Returns the complete path to the file (ie: /tmp/generated-folder/filename)

TemporaryFile::getPathname(): string

::remove()

Removes the file from filesystem.

TemporaryFile::remove()

Temporary directory management

::__construct()

TemporaryDirectory::__construct(string $dir = null, string $prefix = 'phpgenerated')

Examples:

// create a new directory
$directory = new TemporaryDirectory();

::getTemporaryFile()

Create a TemporaryFile from the directory generated.

TemporaryDirectory::getTemporaryFile(): TemporaryFile

::remove()

Removes the directory.

TemporaryDirectory::remove(bool $force = false): void

If force is specified to true, it will remove the directory even if it has files inside.

::getPathname()

Returns the complete path to the folder (ie: /tmp/folder-name)

TemporaryDirectory::getPathname(): string

nekland/tools 适用场景与选型建议

nekland/tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 406.16k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2016 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nekland/tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nekland/tools 我们能提供哪些服务?
定制开发 / 二次开发

基于 nekland/tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 406.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 12
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-03