Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Remove illuminate/support dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbruce committed Sep 19, 2021
1 parent 39fd6ec commit 2dcf253
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/Helpers/String.php
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);
}
}
2 changes: 1 addition & 1 deletion src/Read/HtmlContentCategoryIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Eightfold\HtmlSpec\Read;

use Illuminate\Support\Str;
use Eightfold\HtmlSpec\Helpers\String as Str;

use Eightfold\HtmlSpec\Compiler;

Expand Down
2 changes: 1 addition & 1 deletion src/Write/HtmlRolesIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Eightfold\HtmlSpec\Read\HtmlRolesIndex as HtmlRolesIndexReader;

use Illuminate\Support\Str;
use Eightfold\HtmlSpec\Helpers\String as Str;

use Eightfold\HtmlSpec\Compiler;

Expand Down

0 comments on commit 2dcf253

Please sign in to comment.