Closed rick-nu closed 9 years ago
@berry-langerak: alternatives for the function names:
$f = new Particle\Filter;
$f->clean('first_name')->trim(); // Option 1
$f->refine('first_name')->trim(); // Option 2
$f->update('first_name')->trim(); // Option 3
$f->set('first_name')->trim(); // Option 4
$f->filter([ // I think this should be filter
'first_name' => 'Rick'
]);
Meh. I agree on the last one (that that should be filter), but none of the options really cover the load :(
@RickvdStaaij Hm. So what do you think about this?
$f = new Particle\Filter;
$f->sanitize('first_name')->trim();
$f->filter($values);
Filtering is for sanitizing values, after all? :)
@berry-langerak Yes, but I think sanitize
is not really a common word, something you would easily remember. If you look at it from that perspective, clean
might be easier. Or maybe sift
?
And if we can't find the proper replacement for filter
, then what about
$f->filterValue('first_name')->trim();
or just
$f->value('first_name')->trim();
.
I whole-heartily disagree with your assertion that sanitize is not a common word. It's actually rather common, also in the context of filtering values. Then, you could argue that value
might be better:
$f = new Filter;
$f->value('first_name')->trim();
$f->value('premium_sms')->bool();
$values = $f->filter($values);
I like it. Go! :)
value
it is!
Also will this api be included?
$f->value('*')->trim();
$f->value('premium_sms')->bool();
altenative something as
$f->allValues()->trim();
$f->value('premium_sms')->bool();
Which will then apply the filters to all values in the context and on top of that a separately filter chain to a single value.
@NickBelhomme $f->all()->trim()
is already included, we are also thinking of adding:
$f->values(['first_name', 'last_name'])->trim()
But that's a bit more complex. However, you can expect that for version 1. I will release v0.1.0 when I added all filters featured in the readme, after that I will look into that.
you guys are the best! Looking forward to using it.
@RickvdStaaij I think I also miss a callback filter rule, which may come in handy if you have a weird filter rule you just want to do once (e.g. prepend a "0", if the value doesn't start with "0").
Might be nice to add a prepend and a append anyway too, I've added those and callable to the list in #4.
Default filter-rules have been implemented and have been released in version 0.1.0, closing.
With API:
This issue is currently picked up in #4