Giter Club home page Giter Club logo

str's Introduction

Build Status Coverage Status

in dev, please do not use in production

str/str

$s = new Str('Hello, 世界');
$s->last(2); // 世界
$s->chars(); // ['H','e','l','l','o',',',' ','世','界']

$s
    ->ensureLeft('H') // Hello, 世界
    ->ensureRight('!!!') // Hello, 世界!!!
    ->trimRight('!') // Hello, 世界
    ->append('Str say - '); // Str say - Hello, 世界

$send = function (string $s) {};
$send((string)$s); // same
$send($s->toString()); // same
$send($s->getString()); // same

A fast string manipulation library with multibyte support. Based on "Stringy" library, with focus on speed.

Lib uses php7 features and does not throw any exceptions (because all input parameters are strongly typed). The code is completely covered by unit tests)

install

Requirements:

  • php7.0
composer require str/str

support List

Done

  • ensureLeft
  • ensureRight
  • hasPrefix
  • hasSuffix
  • contains
  • replace - add limit param
  • toLowerCase
  • toUpperCase
  • trim
  • trimLeft
  • trimRight
  • append
  • prepend
  • at
  • substr
  • chars
  • first
  • last
  • length
  • indexOf
  • indexOfLast
  • countSubstr
  • containsAll
  • containsAny
  • startsWith
  • startsWithAny
  • endsWith
  • endsWithAny
  • pad
  • padBoth
  • padLeft
  • padRight
  • insert
  • removeLeft
  • removeRight
  • repeat
  • reverse
  • shuffle
  • between
  • camelize
  • collapseWhitespace
  • dasherize
  • delimit
  • lowerCaseFirst
  • regexReplace
  • upperCaseFirst
  • isUUIDv4

Todo Stringy

  • hasLowerCase
  • hasUpperCase
  • htmlDecode
  • htmlEncode
  • humanize
  • isAlpha
  • isAlphanumeric
  • isBase64
  • isBlank
  • isHexadecimal
  • isJson
  • isLowerCase
  • isSerialized
  • isUpperCase
  • lines
  • longestCommonPrefix
  • longestCommonSuffix
  • longestCommonSubstring
  • safeTruncate
  • slugify
  • slice
  • split
  • stripWhitespace
  • surround
  • swapCase
  • tidy
  • titleize
  • toAscii
  • toBoolean
  • toSpaces
  • toTabs
  • toTitleCase
  • truncate
  • underscored
  • upperCamelize

Todo New

benchmark

./vendor/bin/phpbench run --report=str
./vendor/bin/phpbench run -o markdown --report=str

Test subjects:


subject mode mem_peak diff
bench_StrStatic 239.000μs 1,328,496b 1.00x
bench_Str 482.000μs 1,355,320b 2.02x
bench_Stringy 1,479.000μs 1,872,552b 6.19x
bench_StringyStatic 1,790.000μs 1,894,024b 7.49x

str's People

Contributors

fe3dback avatar irhen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.