Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ $value = \TraderInteractive\Filter\Strings::explode('abc,def,ghi');
assert($value === ['abc', 'def', 'ghi']);
```

#### Strings::stripControlCharacters
Aliased in the filterer as `strip-cchars`, this filter removes control characters from a given string optionally replacing them with the given replacement string
```php
$value = \TraderInteractive\Filter\Strings::stripControlCharacters("Hello\x00\tWorld\nTest\x7F", ' ');
assert($value === 'Hello World Test ');
```

#### Strings::stripEmoji
Aliased in the filterer as `strip-emoji`, this filter removes emoji characters from a given string optionally replacing them with the given replacement string
```php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"traderinteractive/filter-dates": "^4.0",
"traderinteractive/filter-floats": "^4.0",
"traderinteractive/filter-ints": "^4.0",
"traderinteractive/filter-strings": "^4.2"
"traderinteractive/filter-strings": "^4.3"
Comment thread
chadicus marked this conversation as resolved.
},
"require-dev": {
"phpunit/phpunit": "^9.0",
Expand Down
1 change: 1 addition & 0 deletions src/Filterer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class Filterer implements FiltererInterface
'phone' => PhoneFilter::class . '::filter',
'redact' => '\\TraderInteractive\\Filter\\Strings::redact',
'string' => '\\TraderInteractive\\Filter\\Strings::filter',
'strip-cchars' => Strings::class . '::stripControlCharacters',
'strip-emoji' => Strings::class . '::stripEmoji',
'strip-tags' => '\\TraderInteractive\\Filter\\Strings::stripTags',
'time-of-day' => TimeOfDayFilter::class . '::filter',
Expand Down
17 changes: 17 additions & 0 deletions tests/FiltererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,23 @@ function (int $input, int $fieldOneValue) : int {
[],
],
],
'strip-cchars' => [
'spec' => [
'field' => [['strip-cchars', ' ']],
],
'input' => [
'field' => "Hello\x00\tWorld\nTest\x7F",
],
'options' => [],
'result' => [
true,
[
'field' => 'Hello World Test ',
],
null,
[],
],
],
];
}

Expand Down
Loading