PHP code example of fater / typography

1. Go to this page and download the library: Download fater/typography library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fater / typography example snippets




use Fater\Typography\Typography;

$formattedText = Typography::init()->apply('Your text');

echo $formattedText;



use Fater\Typography\Rules\Rule;
use Your\Namespace\Rules;

class YourOwnRule extends Rule
{
    public function handle(string $text): string
    {
        // Your code modification rules
        $text .= ' World!';
        
        // Return formatted text
        return $text;
    }
}



use Fater\Typography\Typography;
use Fater\Typography\TypographyRules;
use Your\Namespace\Rules\YourOwnRule;

$rules = TypographyRules::init()->addRules([YourOwnRule::class]);

// Text will be formatted with default list of rules including your rule
$formattedText = Typography::init($rules) // Set rules instance with your rule
    ->apply('Hello');



use Fater\Typography\Typography;
use Fater\Typography\TypographyRules;

$rules = TypographyRules::init()
    ->clearAll()
    ->addRules([YourOwnRule::class]);

// Text will be formatted only with your rule
$formattedText = Typography::init($rules) // Set rules instance with your rule
    ->apply('Hello');

echo $formattedText;