2015-02-25 13:37 GMT+03:00 Thomas Gielfeldt <tho...@gielfeldt.dk>:

> Yeah, but the "problem" with this, is that your class' sort method, you
> have to implement all the possible permutations the flags can produce. This
> basically just squeezes the 11 functions into 1. The 1 interface with
> sort() and usort() splits this into 2 functions (8+3). With that in mind,
> I'm more inclined to choose the 4 interface approach.



For that case, move all configurations to the several classes and configure
these flags in the concrete constructors. Interface will be more simple:

interface Sortable {
    const ASC = 1;
    const DESC = 2;

    public function sort($direction = self::ASC, callable $callback = null);
}

class KeySorter implements Sortable {}

Reply via email to