On 06/16/2016 03:38 PM, Matthew Weier O'Phinney wrote:
On Wed, Jun 15, 2016 at 3:31 PM, Larry Garfield <[email protected]> wrote:
A corresponding PR has been filed here:

https://github.com/php-fig/fig-standards/pull/775

Including the following open question: Should we add utility methods to
LinkCollectionInterface to get just templated or untemplated values? Or does
that result in too much complexity alongside getLinksByRel()? Or should that
and getLinks() get a parameter to filter by templated or not?
I'd argue that we leave filtering to the consumer. This can be done when
iterating the collection, or could be delegated to a first-class collection:

     $nonTemplatedLinks = new Collection($linkCollection->getLinks())
         ->reject(LinkInterface $link) {
             return $link->isTemplated();
         });

We did similarly with PSR-7, disallowing things like `withoutHeaders()` (note
the plural) and `clearHeaders()` in favor of a single `withoutHeader()`
(singular) method, among others. The rationale is:

- One method versus many (keeps interface focused, and eliminates TMTOWTDI
   problems)
- Boolean flags as arguments are difficult to understand at invocation:
   `$links->getLinksByRel('foo', true)` (what does `true` imply here?)

Since the methods in `LinkCollection` are already returning arrays (or iterable
objects), we'd either need to add more methods, or add flags, which leaves me
inclined to leave filtering up to the consumer.

Makes sense.  Care to merge that PR then? :-)

--Larry Garfield

--
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/576851D6.2040901%40garfieldtech.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to