Closed marcioAlmada closed 10 years ago
The standard str_pad()
accepts strings for padding as well as just single characters. Is that what you would expect for ustring
as well?
@datibbaw in this case, equivalence means to have same args as str_pad
:
abstract class UString implements Iterable {
//...
public function pad(int $pad_length [, UString $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]]);
//...
}
I've started branch ustring-pad for this feature; it currently only supports pad strings with one character and uses a single space by default.
+1
@datibbaw whoaa, that was fast!
I think a single character padding string (default being a space) makes totally sense :)
While that does make sense, it's not consistent with the current implementation of str_pad and might be a wtf moment in the real world when you pass more than one char as padding ...
@datibbaw suggest you try to make consistent with current impl, then merge it ... also, add test ...
Yes, I fully intend to make it compatible with PHP's.
UnicodeString
already had support for single character padding, so I've carved that out as the default case; the special case of supporting longer padding will need some cruder code ;-)
Thanks, @krakjoe you're right :)
@datibbaw you awsome :)
Because this would be really useful.