# Str

Str is a collection of classes that interact with strings. Namespace Chevere\Components\Str holds all the Str classes, offering a myriad of string related functionalities.

# String Manipulation

Manipulating strings refers to the process of altering an argument of type string.

StrInterface describe the interface for a component in charge of string manipulation.

use Chevere\Components\Str\Str;

$str = (new Str('  THE STRING  '))
    ->lowercase()
    ->stripWhitespace();

$result = $str->toString();
// = "thestring";

In the code above, THE STRING is manipulated to result in thestring.

# String Asserting

Asserting strings refers to the process of asserting an argument of type string against methods that throws Throwable when failing to assert.

# StrAssert

StrAssert describe the interface for a component in charge of string asserting.

use new Chevere\Components\Str\StrAssert;

(new StrAssert('A String'))
    ->notEmpty()
    // string isn't empty
    ->notCtypeSpace();
    // Throws StrCtypeSpaceException

In the code above, executing notEmpty won't raise any exception as $string is not empty, but executing notCtypeSpace will raise an exception as $string contains c-type spaces.

# String Bool

Bool string refers to the process of validate an argument of type string against methods that returns bool.

# StrBool

StrBoolInterface describe the interface for a component in charge of string validation.

use new Chevere\Components\Str\StrBool;

$string = 'Chévere es magnífico!';
$strBool = new StrBool($string);
$strBool->endsWith('Rodo'); // false
$strBool->contains('es'); // true
$strBool->startsWith('Chévere'); // true

In the code above, endsWith returns false as $string doesn't ends with Rodo. Passing es to contains method and passing Chévere to startsWith method returns true as the conditions are meet.