MediaWiki master
Wikimedia\Leximorph\Handler\Bidi Class Reference

Bidi. More...

Public Member Functions

 __construct (private readonly Provider $provider,)
 Initializes the Bidi handler with the provider.
 
 process (string $value)
 Applies bidirectional formatting to the provided text.
 

Public Attributes

const LRE = "\xE2\x80\xAA"
 Unicode LEFT-TO-RIGHT EMBEDDING character (U+202A).
 
const PDF = "\xE2\x80\xAC"
 Unicode POP DIRECTIONAL FORMATTING character (U+202C).
 
const RLE = "\xE2\x80\xAB"
 Unicode RIGHT-TO-LEFT EMBEDDING character (U+202B).
 

Detailed Description

Bidi.

The Bidi class applies bidirectional formatting to text by wrapping the input with directional isolation control characters. It detects the primary directionality (left-to-right or right-to-left) of the text and ensures that mixed-direction content is rendered correctly.

Usage Example: echo $bidi->process( 'Hello World' );

Since
1.45
Author
Doğu Abaris (abari.nosp@m.s@nu.nosp@m.ll.ne.nosp@m.t)
Note
https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later

Definition at line 28 of file Bidi.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Leximorph\Handler\Bidi::__construct ( private readonly Provider $provider)

Initializes the Bidi handler with the provider.

Parameters
Provider$providerThe provider instance to use.
Since
1.45

Definition at line 52 of file Bidi.php.

Member Function Documentation

◆ process()

Wikimedia\Leximorph\Handler\Bidi::process ( string $value)

Applies bidirectional formatting to the provided text.

This method determines the primary text direction (LTR or RTL) by examining the first strongly directional codepoint in the string. It then wraps the text with the appropriate directional control characters: LRE and PDF for left-to-right, RLE and PDF for right-to-left. If no strong directionality is detected, the text is returned unmodified.

Parameters
string$valueThe text to format.
Since
1.45
Returns
string The text with directional controls, or the original text.

Definition at line 72 of file Bidi.php.

References Wikimedia\Leximorph\Handler\Bidi\PDF.

Member Data Documentation

◆ LRE

const Wikimedia\Leximorph\Handler\Bidi::LRE = "\xE2\x80\xAA"

Unicode LEFT-TO-RIGHT EMBEDDING character (U+202A).

Definition at line 33 of file Bidi.php.

◆ PDF

const Wikimedia\Leximorph\Handler\Bidi::PDF = "\xE2\x80\xAC"

Unicode POP DIRECTIONAL FORMATTING character (U+202C).

Definition at line 43 of file Bidi.php.

Referenced by Wikimedia\Leximorph\Handler\Bidi\process().

◆ RLE

const Wikimedia\Leximorph\Handler\Bidi::RLE = "\xE2\x80\xAB"

Unicode RIGHT-TO-LEFT EMBEDDING character (U+202B).

Definition at line 38 of file Bidi.php.


The documentation for this class was generated from the following file: