hiroto-k / string-builder
String builder class for PHP.
1.1.0
2022-08-06 05:29 UTC
Requires
- php: ^8.0
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2023-06-06 07:22:10 UTC
README
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');