Skip to content

Commit

Permalink
readme and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamSampaio committed Sep 9, 2024
1 parent 7738d30 commit 4a87000
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# String Utils

![Codecov (with branch)](https://img.shields.io/codecov/c/github/WilliamSampaio/string-utils/master?style=flat-square&logo=codecov)
![GitHub License](https://img.shields.io/github/license/WilliamSampaio/string-utils?style=flat-square)

This library provides a number of features for manipulating strings, such as removing whitespace, accented characters, and more.

## Install

```bash
composer require williamsampaio/string-utils
```

## Usage

```php
<?php

use StringUtils\StringProcessor;

require_once __DIR__ . '/vendor/autoload.php';

$str = 'Wí¨lL/ìãm% \bê$njá@..@mi,m ! m&e(n)#ezes;? sãm*pai|o ';

$str = StringProcessor::removeSpecialCharacters($str);
$str = StringProcessor::ptBrReplaceAccentedCharacters($str);
$str = StringProcessor::trimWhitespaces($str);
$str = StringProcessor::styleTitle($str);

echo $str;

```

**Output:**

```bash
William Benjamim Menezes Sampaio
```

```php
<?php

use StringUtils\StringProcessor;

require_once __DIR__ . '/vendor/autoload.php';

$str = 'Wí¨lL/ìãm% \bê$njá@..@mi,m ! m&e(n)#ezes;? sãm*pai|o ';

$str = StringProcessor::input($str, [
StringProcessor::REMOVE_SPECIAL_CHARACTERS,
StringProcessor::PT_BR_REPLACE_ACCENTED_CHARACTERS,
StringProcessor::TRIM_WHITESPACES,
StringProcessor::STYLE_TITLE
]);

echo $str;

```

**Output:**

```bash
William Benjamim Menezes Sampaio
```

## License

The MIT License (MIT). Please see [License File](https://raw.githubusercontent.com/WilliamSampaio/string-utils/master/LICENSE) for more information.
33 changes: 33 additions & 0 deletions example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use StringUtils\StringProcessor;

require_once __DIR__ . '/vendor/autoload.php';

$str = 'Wí¨lL/ìãm% \bê$njá@..@mi,m ! m&e(n)#ezes;? sãm*pai|o ';

$str = StringProcessor::removeSpecialCharacters($str);
$str = StringProcessor::ptBrReplaceAccentedCharacters($str);
$str = StringProcessor::trimWhitespaces($str);
$str = StringProcessor::styleTitle($str);

echo $str;

echo '<br>';
// OR

$str = 'Wí¨lL/ìãm% \bê$njá@..@mi,m ! m&e(n)#ezes;? sãm*pai|o ';

$str = StringProcessor::removeSpecialCharacters($str);
$str = StringProcessor::ptBrReplaceAccentedCharacters($str);
$str = StringProcessor::trimWhitespaces($str);
$str = StringProcessor::styleTitle($str);

$str = StringProcessor::input($str, [
StringProcessor::REMOVE_SPECIAL_CHARACTERS,
StringProcessor::PT_BR_REPLACE_ACCENTED_CHARACTERS,
StringProcessor::TRIM_WHITESPACES,
StringProcessor::STYLE_TITLE
]);

echo $str;

0 comments on commit 4a87000

Please sign in to comment.