Ease extension of Slugify class - #44
Conversation
|
First you should split this up into two Pull Requests. These are completely different things. I will merge the PR to change the visibility of the properties, but I don't think it is useful to change the interface of |
|
You are right, this should be split into two pull requests. I'll do it right away. |
|
Done, just removed the last commit and pushed it again (with --force) |
Ease extension of Slugify class
|
Regarding the regular expression. If there is need to modify it, there should be another way than supplying another parameter to |
|
Yes, I like the idea of using a property. A protected property could be overriden, but maybe a setter would be good too. |
|
Yes, please make another PR. Thanks. |
I made a few minor changes.
Changed the visibility of rules and rulesets properties to protected to allow them to be overriden or used in child classes while extending Slugify.
Maybe using a getter for the rules property would do the same job, but this was my approach.
Added a third optional param to the
slufigymethod with the regular expression to be applied to the string.I made this because I needed to allow other characters in the slug, like dots for filenames. I didn't want
My Cool File.zipto becomemy-cool-file-zipbutmy-cool-file.zip.I wasn't sure if that argument should be set in the constructor or in this method, but I think this is good enough.
I was thinking also on giving the option to define if the string should be lowered or not, but I'm not sure what's the best way to do that.