-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from yaquawa/inject_slugify
Make sluggifier injectable; thanks for your contribution @yaquawa! I will be releasing a new version with this change in the next day or two.
- Loading branch information
Showing
2 changed files
with
16 additions
and
8 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
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 |
---|---|---|
|
@@ -21,13 +21,14 @@ | |
namespace TOC; | ||
|
||
use Cocur\Slugify\Slugify; | ||
use Cocur\Slugify\SlugifyInterface; | ||
|
||
/** | ||
* UniqueSluggifier creates slugs from text without repeating the same slug twice per instance | ||
* | ||
* @author Casey McLaughlin <[email protected]> | ||
*/ | ||
class UniqueSluggifier | ||
class UniqueSluggifier implements SlugifyInterface | ||
{ | ||
/** | ||
* @var Slugify | ||
|
@@ -54,11 +55,12 @@ public function __construct(Slugify $slugify = null) | |
* Slugify | ||
* | ||
* @param string $text | ||
* @param null $options | ||
* @return string | ||
*/ | ||
public function slugify(string $text): string | ||
public function slugify($text, $options = null): string | ||
{ | ||
$slugged = $this->slugify->slugify($text); | ||
$slugged = $this->slugify->slugify($text, $options); | ||
|
||
$count = 1; | ||
$orig = $slugged; | ||
|