On 06/20/2016 03:28 PM, Larry Garfield wrote:
On 06/16/2016 03:38 PM, Matthew Weier O'Phinney wrote:
On Wed, Jun 15, 2016 at 3:31 PM, Larry Garfield
<la...@garfieldtech.com> 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
Since there was no pushback for over 20 days, I went ahead and merged it
myself.
--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 php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/577EEE43.1020608%40garfieldtech.com.
For more options, visit https://groups.google.com/d/optout.