Skip to content

Commit

Permalink
Merge pull request #202 from froschdesign/hotfix/docs/remove-i18n-fil…
Browse files Browse the repository at this point in the history
…ters

Remove sections on Alnum, Alpha, NumberFormat, and NumberParse
  • Loading branch information
gsteel authored Dec 4, 2024
2 parents 46b5d30 + 82a71f2 commit 08e0bb9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 191 deletions.
8 changes: 8 additions & 0 deletions docs/book/v3/filter-chains.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Filter Chains

> MISSING: **Installation Requirements**
> The following examples use the [`Alpha` filter from the `laminas/laminas-i18n`](https://docs.laminas.dev/laminas-i18n/filters/alpha/).
> Make sure to install the required package before running the examples.
>
> ```bash
> $ composer require laminas/laminas-i18n
> ```
Often, multiple filters should be applied to some value in a particular order.
For example, a login form accepts a username that should be lowercase and
contain only alphabetic characters.
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v3/inflector.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ provided will be used to inflect the text. Classes are typically specified
using a short name indicating the filter name stripped of any common prefix.

As an example, you can use any laminas-filter concrete implementations; however,
instead of referring to them as `Laminas\I18n\Filter\Alpha` or
`Laminas\Filter\StringToLower`, you'd specify only `Alpha` or `StringToLower`.
instead of referring to them as `Laminas\Filter\Boolean` or
`Laminas\Filter\StringToLower`, you'd specify only `Boolean` or `StringToLower`.

### Using Custom Filters

Expand Down
189 changes: 0 additions & 189 deletions docs/book/v3/standard-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,97 +27,6 @@ echo $allowList->filter('allowed-2'); // => 'allowed-2'
echo $allowList->filter('not-allowed'); // => null
```

## Alnum

The `Alnum` filter can be used to return only alphabetic characters and digits
in the unicode "letter" and "number" categories, respectively. All other
characters are suppressed.

This filter is part of the laminas-i18n package; you will need to include that
package in your application to use it.

### Supported Options

The following options are supported for `Alnum`:

```php
Alnum([ boolean $allowWhiteSpace [, string $locale ]])
```

- `$allowWhiteSpace`: If set to true, then whitespace characters are allowed.
Otherwise they are suppressed. Default is `false` (whitespace is not allowed).
Methods for getting/setting the `allowWhiteSpace` option are also available:
`getAllowWhiteSpace()` and `setAllowWhiteSpace()`.

- `$locale`: The locale string used in identifying the characters to filter
(locale name, e.g. `en_US`). If unset, it will use the default locale
(`Locale::getDefault()`). Methods for getting/setting the locale are also
available: `getLocale()` and `setLocale()`.

### Basic Usage

```php
// Default settings, deny whitespace
$filter = new \Laminas\I18n\Filter\Alnum();
echo $filter->filter('This is (my) content: 123');
// Returns 'Thisismycontent123'

// First param in constructor is $allowWhiteSpace
$filter = new \Laminas\I18n\Filter\Alnum(true);
echo $filter->filter('This is (my) content: 123');
// Returns 'This is my content 123'
```

NOTE: **Supported Languages**
`Alnum` works on almost all languages, except: Chinese, Japanese and Korean.
Within these languages, the english alphabet is used instead of the characters from these languages.
The language itself is detected using the `Locale` class.

## Alpha

The `Alpha` filter can be used to return only alphabetic characters in the unicode "letter"
category. All other characters are suppressed.

This filter is part of the laminas-i18n package; you will need to include that
package in your application to use it.

### Supported Options

The following options are supported for `Alpha`:

```php
Alpha([ boolean $allowWhiteSpace [, string $locale ]])
```

- `$allowWhiteSpace`: If set to true then whitespace characters are allowed.
Otherwise they are suppressed. Default is `false` (whitespace is not allowed).
Methods for getting/setting the allowWhiteSpace option are also available:
`getAllowWhiteSpace()` and `setAllowWhiteSpace()`.

- `$locale`: The locale string used in identifying the characters to filter
(locale name, e.g. `en_US`). If unset, it will use the default locale
(`Locale::getDefault()`). Methods for getting/setting the locale are also
available: `getLocale()` and `setLocale()`.

### Basic Usage

```php
// Default settings, deny whitespace
$filter = new \Laminas\I18n\Filter\Alpha();
echo $filter->filter('This is (my) content: 123');
// Returns 'Thisismycontent'

// Allow whitespace
$filter = new \Laminas\I18n\Filter\Alpha(true);
echo $filter->filter('This is (my) content: 123');
// Returns 'This is my content '
```

NOTE: **Supported Languages**
`Alpha` works on almost all languages, except: Chinese, Japanese and Korean.
Within these languages, the english alphabet is used instead of the characters from these languages.
The language itself is detected using the `Locale` class.

## BaseName

`Laminas\Filter\BaseName` allows you to filter a string which contains the path to
Expand Down Expand Up @@ -916,104 +825,6 @@ $filter = new \Laminas\Filter\ToString();
$filter->filter(['muppet' => 'Kermit']); // ['muppet' => 'Kermit']
```

## NumberFormat

The `NumberFormat` filter can be used to return locale-specific number and percentage strings. It
extends the `NumberParse` filter, which acts as wrapper for the `NumberFormatter` class within the
Internationalization extension (Intl).

This filter is part of the laminas-i18n package; you will need to include that
package in your application to use it.

### Supported Options

The following options are supported for `NumberFormat`:

```php
NumberFormat([ string $locale [, int $style [, int $type ]]])
```

- `$locale`: (Optional) Locale in which the number would be formatted (locale
name, e.g. `en_US`). If unset, it will use the default locale
(`Locale::getDefault()`). Methods for getting/setting the locale are also
available: `getLocale()` and `setLocale()`.

- `$style`: (Optional) Style of the formatting, one of the
[format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle).
If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style.
Methods for getting/setting the format style are also available: `getStyle()`
and `setStyle()`.

- `$type`: (Optional) The [formatting type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types)
to use. If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default
type. Methods for getting/setting the format type are also available:
`getType()` and `setType()`.

### Basic Usage

```php
$filter = new \Laminas\I18n\Filter\NumberFormat('de_DE');
echo $filter->filter(1234567.8912346);
// Returns '1.234.567,891'

$filter = new \Laminas\I18n\Filter\NumberFormat('en_US', NumberFormatter::PERCENT);
echo $filter->filter(0.80);
// Returns '80%'

$filter = new \Laminas\I18n\Filter\NumberFormat('fr_FR', NumberFormatter::SCIENTIFIC);
echo $filter->filter(0.00123456789);
// Returns '1,23456789E-3'
```

## NumberParse

The `NumberParse` filter can be used to parse a number from a string. It acts as
a wrapper for the `NumberFormatter` class within the Internationalization
extension (Intl).

This filter is part of the laminas-i18n package; you will need to include that
package in your application to use it.

### Supported Options

The following options are supported for `NumberParse`:

```php
NumberParse([ string $locale [, int $style [, int $type ]]])
```

- `$locale`: (Optional) Locale in which the number would be parsed (locale name,
e.g. `en_US`). If unset, it will use the default locale
(`Locale::getDefault()`). Methods for getting/setting the locale are also
available: `getLocale()` and `setLocale()`.

- `$style`: (Optional) Style of the parsing, one of the
[format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle).
If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style.
Methods for getting/setting the parse style are also available: `getStyle()`
and `setStyle()`.

- `$type`: (Optional) The [parsing type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types)
to use. If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default
type. Methods for getting/setting the parse type are also available:
`getType()` and `setType()`.

### Basic Usage

```php
$filter = new \Laminas\I18n\Filter\NumberParse('de_DE');
echo $filter->filter('1.234.567,891');
// Returns 1234567.8912346

$filter = new \Laminas\I18n\Filter\NumberParse('en_US', NumberFormatter::PERCENT);
echo $filter->filter('80%');
// Returns 0.80

$filter = new \Laminas\I18n\Filter\NumberParse('fr_FR', NumberFormatter::SCIENTIFIC);
echo $filter->filter('1,23456789E-3');
// Returns 0.00123456789
```

## PregReplace

`Laminas\Filter\PregReplace` performs a search using regular expressions and replaces all found elements.
Expand Down

0 comments on commit 08e0bb9

Please sign in to comment.