定制 vantoozz/strings 二次开发

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

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

vantoozz/strings

Composer 安装命令:

composer require vantoozz/strings

包简介

OOP Strings Library

README 文档

README

True OOP library for strings manipulation

Build Status Coverage Status Codacy Badge Packagist

The goal of the library is providing an OOP way for strings manipulations. It works with any object implementing Stringable interface. https://wiki.php.net/rfc/stringable.

Setup

Just run

composer require vantoozz/strings

Transformations

<?php declare(strict_types=1);

use Vantoozz\Strings\Transforms\Acronym;
use Vantoozz\Strings\Transforms\CaseToggled;
use Vantoozz\Strings\Transforms\Reversed;
use Vantoozz\Strings\Transforms\SnakeCased;

use function Vantoozz\Strings\str;

require_once __DIR__ . '/vendor/autoload.php';

$string = str('PHP: Hypertext Preprocessor');

echo new Acronym($string) . PHP_EOL;
echo new CaseToggled($string) . PHP_EOL;
echo new Reversed($string) . PHP_EOL;
echo new SnakeCased($string) . PHP_EOL;

Will output

PHP
php: hYPERTEXT pREPROCESSOR
rossecorperP txetrepyH :PHP
p_h_p:_hypertext_preprocessor

Available transformations

  • Acronym
  • CamelCased
  • CaseToggled
  • KebabCased
  • LowerCased
  • PascalCased
  • Reversed
  • SentenceCased
  • SnakeCased
  • TitleCased
  • UpperCased

Joins

<?php declare(strict_types=1);

use Vantoozz\Strings\Joins\EndingWith;
use Vantoozz\Strings\Joins\Joined;
use Vantoozz\Strings\Joins\StartingWith;

use function Vantoozz\Strings\str;

require_once __DIR__ . '/vendor/autoload.php';

$one = str('aabbc');
$two = str('ccddaa');

echo new Joined($one, $two) . PHP_EOL;
echo new EndingWith($one, $two) . PHP_EOL;
echo new StartingWith($one, $two) . PHP_EOL;

Will output

aabbcccddaa
aabbccddaa
ccddaabbc

Available joins

  • Joined
  • StartingWith
  • EndingWith

Formats

<?php declare(strict_types=1);

use Vantoozz\Strings\Exceptions\InvalidFormatException;
use Vantoozz\Strings\Formats\Email;

use function Vantoozz\Strings\str;

require_once __DIR__ . '/vendor/autoload.php';


try {
    echo new Email(str('user@example.com')) . PHP_EOL;
} catch (InvalidFormatException $e) {
    echo $e->getMessage() . PHP_EOL;
}

try {
    echo new Email(str('user%example.com')) . PHP_EOL;
} catch (InvalidFormatException $e) {
    echo $e->getMessage() . PHP_EOL;
}

Will output

user@example.com
Invalid format

Available formats

  • Email
  • Hostname
  • Ipv4
  • Ipv6
  • Mac
  • Sha1
  • Sha256
  • Url

Composition

<?php declare(strict_types=1);

use Vantoozz\Strings\Formats\Email;
use Vantoozz\Strings\Joins\EndingWith;
use Vantoozz\Strings\Transforms\CaseToggled;

use function Vantoozz\Strings\str;


require_once __DIR__ . '/vendor/autoload.php';

$username = str('User@');
$domain = str('@Example.Com');

echo new CaseToggled(new Email(new EndingWith($username, $domain))) . PHP_EOL;

Will output

uSER@eXAMPLE.cOM

Testing

./vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固