hiroto-k/string-builder

String builder class for PHP.

1.0.0 2018-06-12 18:05 UTC

This package is auto-updated.

Last update: 2019-11-28 13:01:27 UTC


README

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