String builder class for PHP.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.gitignore
.php_cs
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

php-string-builder

Build Status PHP from Packagist Coverage Status License

String builder class for PHP.

<?php

$str = 'Your String';

// Normal PHP.
// Display 'MY STRING'.
echo mb_strtoupper(str_replace('Your', 'My', $str), 'utf-8');

// Using this library.
// Display 'MY STRING'.
use HirotoK\StringBuilder\StringBuilder;

echo StringBuilder::make($str)->replace('Your', 'My')->upcase();

Requirements

  • PHP 7.0 or later
  • mbstring extension

Installation

1, Download this library

Modify require directive in composer.json.

{
  "require": {
    "hiroto-k/string-builder": "1.*"
  }
}

OR

$ composer require hiroto-k/php-string-builder

2, Load vendor/autoload.php file

Load vendor/autoload.php in your codes.

3, Use StringBuilder class

<?php

// Load composer packages.
require "vendor/autoload.php";

// Using StringBuilder class.
use HirotoK\StringBuilder\StringBuilder;

// Create StringBuilder object.
$sb = new StringBuilder('Your string');

// Alias of '__construct'.
// This method is useful to method chain.
$sb = StringBuilder::make('Your string');

License

MIT License