This repository has been archived by the owner on May 24, 2022. It is now read-only.
generated from 8fold/github-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove illuminate/support dependency
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Eightfold\HtmlSpec\Helpers; | ||
|
||
class String | ||
{ | ||
/** | ||
* See Illuminate Support: https://github.com/illuminate/support/blob/master/Str.php | ||
*/ | ||
public static function slug($title, $separator = '-', $language = 'en') | ||
{ | ||
$title = $language ? static::ascii($title, $language) : $title; | ||
|
||
// Convert all dashes/underscores into separator | ||
$flip = $separator === '-' ? '_' : '-'; | ||
|
||
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); | ||
|
||
// Replace @ with the word 'at' | ||
$title = str_replace('@', $separator.'at'.$separator, $title); | ||
|
||
// Remove all characters that are not the separator, letters, numbers, or whitespace. | ||
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', static::lower($title)); | ||
|
||
// Replace all separator characters and whitespace by a single separator | ||
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); | ||
|
||
return trim($title, $separator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters