markenwerk/simple-string-builder

This package is abandoned and no longer maintained. The author suggests using the markenwerk/string-builder package instead.

A basic string builder library providing different string methods written in PHP.

2.0.4 2016-08-09 20:16 UTC

This package is auto-updated.

Last update: 2021-01-18 12:10:19 UTC


README

Build Status Test Coverage Dependency Status SensioLabs Insight Code Climate Latest Stable Version Total Downloads License

A basic string builder library providing different string methods written in PHP.

Attention!

PHP Simple String Builder is abandoned and no longer maintained. Please use PHP String Builder instead.

Installation

{
   	"require": {
        "markenwerk/simple-string-builder": "~2.0"
    }
}

Usage

Autoloading and namesapce

require_once('path/to/vendor/autoload.php');

Building a string

use Markenwerk\SimpleStringBuilder\SimpleStringBuilder;

$builder = new SimpleStringBuilder();
$builder
	->append('a')
	->append(12)
	->append(false)
	->prepend('b')
	->remove(1)
	->replace(0, 'ab')
	->append(true);

$string = $builder->build();
fwrite(STDOUT, 'Result "' . $string . '"' . PHP_EOL);

$substring = $builder->buildSubstring(0, 2);
fwrite(STDOUT, 'Substring result from position 0 and size 2 "' . $substring . '"' . PHP_EOL);

$substring = $builder->buildSubstring(1);
fwrite(STDOUT, 'Substring result from position 1 till the end "' . $substring . '"' . PHP_EOL);

$size = $builder->size();
fwrite(STDOUT, 'Builder holds "' . $size . '" partial strings' . PHP_EOL);

$length = $builder->length();
fwrite(STDOUT, 'Resulting string length is "' . $length . '" characters' . PHP_EOL);

will output the following

Result "ab121"
Substring result from position 0 and size 2 "ab12"
Substring result from position 1 till the end "121"
Builder holds "4" partial strings
Resulting string length is "5" characters

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document.

License

PHP Simple String Builder is under the MIT license.