Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is $underscoreToSpace removed ? #66

Open
Yamakasi opened this issue Jun 13, 2020 · 4 comments
Open

Why is $underscoreToSpace removed ? #66

Yamakasi opened this issue Jun 13, 2020 · 4 comments

Comments

@Yamakasi
Copy link

Hi,

Why is $underscoreToSpace removed from the filter ? It was pretty handy to make underscores hypens of you wanted, or spaces ofcourse.

I hope there is a good reason for it!

Thanks

@lux
Copy link
Collaborator

lux commented Jun 13, 2020

Ah, I must have missed that parameter changing to $separator in a PR, but it looks like you can accomplish the same thing with the separator. I just tested this code:

<?php
  
require 'vendor/autoload.php';

echo URLify::filter ('some_text here', 200, 'en', false, false, true, '-') . PHP_EOL;
echo URLify::filter ('some_text here', 200, 'en', false, false, true, ' ') . PHP_EOL;

And the output is:

some-text-here
some text here

I suppose what was lost was the ability to set it to false in order to preserve underscores (e.g., "some_text-here").

@Yamakasi
Copy link
Author

OK, thanks a lot for the quick response and explanation! That solution also works!

I wasn't sure if it had a reason but you optimized it a lot (which I was doing in the old version) so I was a little bit flabbergasted, sorry for that :)

Does it stay this way or are you going to change/optimize what I described ? Maybe the arg order could be optimized ?

@lux
Copy link
Collaborator

lux commented Jun 14, 2020

I think you're right, filter()'s parameters are getting pretty long and the order isn't necessarily sorted by what's needed most often. Not wanting to break compatibility, for now I've added a new slug() method with the following parameters:

public static function slug ($string, $maxLength = 200, $separator = '-', $language = 'en')

Hopefully that's easier to remember and use for more common cases :)

@Yamakasi
Copy link
Author

Yamakasi commented Jun 14, 2020

@lux Can't say more... Understood, sure, Superb! Thanks!

(I don't know where the zero's come from, can't backspace them as I don't see them)

0000000000000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants