coercive/slugify

Coercive Slugify Utility

1.2.5 2023-06-15 12:17 UTC

This package is auto-updated.

Last update: 2024-10-15 15:15:28 UTC


README

Slugify allows you to clean the characters in a string for treatment of URL rewriting for example. Other options can detect proper names, clean spaces, move text into utf8 etc ...

Get

composer require coercive/slugify

Usage

URL

use Coercive\Utility\Slugify;

$sTitleArticle = 'My title is not made to work with a URL rewriting directly, it must be processed before.';
$sSlug = (new Slugify)->clean($sTitleArticle);

# GIVE : my-title-is-not-made-to-work-with-a-url-rewriting-directly-it-must-be-processed-before

SUMMARY

use Coercive\Utility\Slugify;

$sText = 'Long text ... Very Long Text ...';
$sSummary = (new Slugify)->substrText($sText);

# GIVE : 300chars text

$sSummary = (new Slugify)->substrText($sText, 500);

# GIVE : 500chars text

NAME

use Coercive\Utility\Slugify;

$sName = 'Mary Antoinette';
$bIsName = (new Slugify)->pregName($sName);

# True

$sName = '@Not A valid name !';
$bIsName = (new Slugify)->pregName($sName);

# False

TO UTF8

use Coercive\Utility\Slugify;

$sString = '!W~"·øΥψ';
$sUtf8String = (new Slugify)->toUTF8($sString);