2017 © Pedro Peláez
 

windwalker-package string

Windwalker String package

image

windwalker/string

Windwalker String package

  • Saturday, July 28, 2018
  • by asika32764
  • Repository
  • 3 Watchers
  • 0 Stars
  • 5,529 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 52 Versions
  • 10 % Grown

The README.md

Windwalker String

Windwalker String package provides UTF-8 string operation, it is a Joomla String fork but added more functions., (*1)

Installation via Composer

Add this to the require block in your composer.json., (*2)

``` json { "require": { "windwalker/string": "~3.0" } }, (*3)


## New Str Class After 3.2, Windwalker has a new `Str` class and we will continue replace all old `StringHelper` will it in the future: ```php use Windwalker\String\Str; string : Str::getChar($string, $pos, $encoding = null); string : Str::between($string, $start, $end, $offset = 0, $encoding = null); string : Str::collapseWhitespaces($string); bool : Str::contains($string, $search, $caseSensitive = true, $encoding = null); bool : Str::endsWith($string, $search, $caseSensitive = true, $encoding = null); bool : Str::startsWith($string, $target, $caseSensitive = true, $encoding = null); string : Str::ensureLeft($string, $search, $encoding = null); string : Str::ensureRight($string, $search, $encoding = null); bool : Str::hasLowerCase($string, $encoding = null); bool : Str::hasUpperCase($string, $encoding = null); bool : Str::match($pattern, $string, $option = 'msr', $encoding = null); string : Str::insert($string, $insert, $position, $encoding = null); bool : Str::isLowerCase($string); bool : Str::isUpperCase($string); string : Str::first($string, $length = 1, $encoding = null); string : Str::last($string, $length = 1, $encoding = null); string : Str::intersectLeft($string1, $string2, $encoding = null); string : Str::intersectRight($string1, $string2, $encoding = null); string : Str::intersect($string1, $string2, $encoding = null); string : Str::pad($string, $length = 0, $substring = ' ', $encoding = null);; string : Str::padLeft($string, $length = 0, $substring = ' ', $encoding = null);; string : Str::padRight($string, $length = 0, $substring = ' ', $encoding = null);; string : Str::removeChar($string, $offset, $length = null, $encoding = null); string : Str::removeLeft($string, $search, $encoding = null); string : Str::removeRight($string, $search, $encoding = null); string : Str::slice($string, $start, $end = null, $encoding = null); string : Str::substring($string, $start, $end = null, $encoding = null); string : Str::surround($string, $substring = ['"', '"']); string : Str::toggleCase($string, $encoding = null); string : Str::truncate();; string : Str::map($string, callable $callback, $encoding = null); string : Str::filter($string, callable $callback, $encoding = null); string : Str::reject($string, callable $callback, $encoding = null);

New StringObject

StringObject is a class to help us manipulation string by OO way., (*4)

Create string object:, (*5)

$str = str('Hello');

// OR

$str = new StringObject('Hello');
$str = StringObject::create('Hello');

Usage

$str[3]; // Get letter

// Iterator
foreach ($str as $letter)
{
    echo $letter
}

// Chaining modify, it is a immutable object, must reuturn self.
$str = $str->toUpperCase()
    ->trimLeft()
    ->truncate();

// to string
echo $str;

Methods

$str->count();
$str->getString();
$str->withString($string);
$str->toLowerCase();
$str->toUpperCase();
$str->length();
$str->chop($length = 1);
$str->replace($search, $replacement, &$count = null);
$str->compare($compare, $caseSensitive = true);
$str->reverse();
$str->substrReplace($replace, $start, $offset = null);
$str->trimLeft($charlist = null);
$str->trimRight($charlist = null);
$str->trim($charlist = null);
$str->upperCaseFirst();
$str->lowerCaseFirst();
$str->upperCaseWords();
$str->substrCount($search, $caseSensitive = true);
$str->indexOf($search);
$str->indexOfLast($search);
$str->explode($delimiter, $limit = null);
$str->apply(callable $callback);
$str->getChar(int $pos);
$str->between(string $start, string $end, int $offset = 0);
$str->collapseWhitespaces(string $string);
$str->contains(string $search, bool $caseSensitive = true);
$str->endsWith(string $search, bool $caseSensitive = true);
$str->startsWith(string $target, bool $caseSensitive = true);
$str->ensureLeft(string $search);
$str->ensureRight(string $search);
$str->hasLowerCase();
$str->hasUpperCase();
$str->match(string $pattern, string $option = 'msr');
$str->insert(string $insert, int $position);
$str->isLowerCase();
$str->isUpperCase();
$str->first(int $length = 1);
$str->last(int $length = 1);
$str->intersectLeft(string $string2);
$str->intersectRight(string $string2);
$str->intersect(string $string2);
$str->pad(int $length = 0, string $substring = ' ');
$str->padLeft(int $length = 0, string $substring = ' ');
$str->padRight(int $length = 0, string $substring = ' ');
$str->removeChar(int $offset, int $length = null);
$str->removeLeft(string $search);
$str->removeRight(string $search);
$str->slice(int $start, int $end = null);
$str->substring(int $start, int $end = null);
$str->surround($substring = ['"', '"']);
$str->toggleCase();
$str->truncate(int $length, string $suffix = '', bool $wordBreak = true);
$str->map(callable $callback);
$str->filter(callable $callback);
$str->reject(callable $callback);

Simple Template Engine

Simple variable replace., (*6)

``` php use Windwalker\String\SimpleTemplate;, (*7)

$string = 'Hello my name is: {{ name }}~~~!!!';, (*8)

SimpleTemplate::render($string, array('name' => 'Simon')); // Hello my name is Simon~~~!!!, (*9)


Multi-level variable. ``` php $string = 'Hello my name is: {{ user.name }} and ID is: {{ user.id }}~~~!!!'; $array = array( 'user' => array( 'name' => 'Simon', 'id' => 123 ) ); SimpleTemplate::render($string, $array); // Hello my name is Simon and ID is: 123~~~!!!

Custom Tags:, (*10)

``` php $string = 'Hello my name is: {$ name $}~~~!!!';, (*11)

SimpleTemplate::render($string, array('name' => 'Simon'), array('{$', '$}'); // Hello my name is Simon~~~!!!, (*12)


## Utf8String Utf8String is a wrap of `phputf8` library: ``` php use Windwalker\String\Utf8String; $string = '這是一個最美的小情歌'; Utf8String::substr($string, 0, 5); // '這是一個最' Utf8String::strlen($string); // 10 // More methods Utf8String::is_ascii($string); Utf8String::strpos($str, $search, $offset = false); Utf8String::strrpos($str, $search, $offset = 0); Utf8String::strtolower($string); Utf8String::strtoupper($string); Utf8String::str_ireplace($search, $replace, $str, $count = null); Utf8String::str_split($str, $split_len = 1); Utf8String::strcasecmp($str1, $str2, $locale = false); Utf8String::strcmp($str1, $str2, $locale = false); Utf8String::strcspn($str, $mask, $start = null, $length = null); Utf8String::stristr($str, $search); Utf8String::strrev($string); Utf8String::strspn($str, $mask, $start = null, $length = null); Utf8String::substr_replace($str, $repl, $start, $length = null); Utf8String::ltrim($str, $charlist = null); Utf8String::rtrim($str, $charlist = null); Utf8String::trim($str, $charlist = null); Utf8String::ucfirst($str, $delimiter = null, $newDelimiter = null); Utf8String::ucwords($string); Utf8String::transcode($source, $from_encoding, $to_encoding); // Equals to iconv()) Utf8String::valid($string); Utf8String::compliant($string); Utf8String::unicode_to_utf8($string); Utf8String::unicode_to_utf16($string);

StringHelper

Empty String Determine

isEmpty(), (*13)

``` php use Windwalker\String\StringHelper;, (*14)

StringHelper::isEmpty(''); // true StringHelper::isEmpty(0); // false StringHelper::isEmpty(array()); // true StringHelper::isEmpty(null); // true, (*15)


isZero() ``` php StringHelper::isZero(0); // true StringHelper::isZero('0'); // true StringHelper::isZero(''); // false StringHelper::isZero(null); // false

Quote

An useful method to quate a string., (*16)

``` php // Default quote is " StringHelper::quote('foo'); // "foo", (*17)

// Custom quotes StringHelper::quote('foo', array('{{', '}}')); // {{foo}}, (*18)

// Backquote StringHelper::backquote('foo'); // foo, (*19)


### More Methods increment() ``` php StringHelper::increment('Title'); // Title (2) StringHelper::increment('Title', StringHelper::INCREMENT_STYLE_DASH); // Title-2

at(), (*20)

``` php StringHelper::at('歡迎光臨', 2); // 光, (*21)


collapseWhitespace() ``` php StringHelper::collapseWhitespace('Welcome to Windwalker'); // 'Welcome to Windwalker'

endsWith(), (*22)

``` php StringHelper::endsWith('歡迎光臨', '光臨' [, $caseSensive = true]); // true, (*23)


startsWith() ``` php StringHelper::startsWith('歡迎光臨', '歡迎' [, $caseSensive = true]); // true

``` php // Default callback is array_push StringHelper::explode('.', 'foo.bar', 3); // array('foo', 'bar', null);, (*24)

// Shift null StringHelper::explode('.', 'foo.bar', 3, 'array_shift'); // array(null, 'foo', 'bar');, (*25)

// Limit StringHelper::explode('.', 'foo.bar.yoo', 2); // array('foo', 'bar.yoo');, (*26)

// Useful to use list(), (*27)

list($foo, $bar, $yoo) = StringHelper::explode('.', 'foo.bar', 3);, (*28)


## StringInflector ``` php use Windwalker\String\StringInflector; $inflector = StringInflector::getInstance(); $string = 'category'; if ($inflector->isSingular($string)) { $string = $inflector->toPular(); // categories } if ($inflector->isPlural($string)) { $string = $inflector->toSingular(); // category }

The Versions

28/07 2018

dev-master

9999999-dev https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

28/07 2018

3.4.4

3.4.4.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

08/07 2018

3.4.3

3.4.3.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

07/07 2018

3.4.2

3.4.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

15/06 2018

3.4.1

3.4.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

01/03 2018

dev-test

dev-test https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

01/03 2018

3.3.1

3.3.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

01/03 2018

3.3.2

3.3.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

01/03 2018

3.4

3.4.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

20/02 2018

3.3

3.3.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

15/07 2017

3.2.5

3.2.5.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

15/07 2017

3.2.6

3.2.6.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

15/07 2017

3.2.7

3.2.7.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

15/07 2017

3.2.8

3.2.8.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

25/06 2017

3.2.4

3.2.4.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

10/06 2017

3.2.2

3.2.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

10/06 2017

3.2.3

3.2.3.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

05/06 2017

3.2.1

3.2.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

05/06 2017

3.2

3.2.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework string windwalker

21/03 2017

3.1.4

3.1.4.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

21/03 2017

3.1.5

3.1.5.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

21/03 2017

3.1.6

3.1.6.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

19/11 2016

3.1.3

3.1.3.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

11/10 2016

3.1

3.1.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

11/10 2016

3.1.1

3.1.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

11/10 2016

3.1.2

3.1.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

18/07 2016

3.0

3.0.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

18/07 2016

3.0.1

3.0.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

06/07 2016

3.0-beta2

3.0.0.0-beta2 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

04/07 2016

3.0-beta

3.0.0.0-beta https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

23/03 2016

2.1.8

2.1.8.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

23/03 2016

2.1.9

2.1.9.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

12/02 2016

2.1.7

2.1.7.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

07/09 2015

2.1.2

2.1.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

07/09 2015

2.1.4

2.1.4.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

07/09 2015

2.1.5

2.1.5.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

07/09 2015

2.1.6

2.1.6.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/08 2015

2.1.1

2.1.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

11/08 2015

2.1

2.1.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

27/07 2015

2.0.9

2.0.9.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

04/04 2015

2.0.8

2.0.8.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.0

2.0.0.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.1

2.0.1.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.2

2.0.2.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.3

2.0.3.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.4

2.0.4.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.5

2.0.5.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.6

2.0.6.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

16/12 2014

2.0.7

2.0.7.0 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

25/11 2014

2.0.0-beta2

2.0.0.0-beta2 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

05/10 2014

2.0.0-alpha

2.0.0.0-alpha https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker

05/10 2014

2.0.0-beta1

2.0.0.0-beta1 https://github.com/ventoviro/windwalker-string

Windwalker String package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework string windwalker