One last question on PSR-13 before I turn it over to Matthew for Review.
Currently, PSR-13 includes only getter methods. As noted in the
metadoc, this is by design as the interfaces could be implemented by
something other than a dumb value object, in which case it is
nonsensical to try and set values. It could also be implemented by an
immutable object, such as a PSR-7 Response, in which case setters would
be incompatible with the Response object's definition.
However, I could also see cases where a standard way to SET the value
for a Link, or to add a Link to a collection. Most notably, a Response
object, where you may want to add links to it in a standard way. Of
course, in such cases we'd have to use a with*() method, a la PSR-7 to
ensure that it's compatible with other immutable value objects.
To that end, I would propose adding one or two additional interfaces
that extend the existing interfaces and add with*() methods. For lack
of a better term, since they're not really mutable, I will call these
"Wither" methods. (A better name is very, very welcome.)
For collections, it would likely contain only a single method,
withLink(LinkInterface), which adds a link object to the collection and
returns the collection. That would cover the Response case.
For links themselves, I expect it would contain withRel(), withHref(),
withAttribute(), withoutAttribute(), and withTemplated().
As before, I've some proof of concept code from a while back here:
https://github.com/Crell/HtmlModel/tree/master/src/Link
Therefore:
1) Add a WitherableLinkInterface extends LinkInterface
2) Add a WitherableLinkCollectionInterface extends LinkCollectionInterface
3) Both
4) Neither
My inclination at the moment is option 2; I can definitely see the use
for that one, and it actually is, I think, key to the common use cases
we've identified (such as transferring links from one value object to
another). The link object itself, eh, I can take it or leave it. I
will probably go that route unless there are any major objections, and
assuming we can come up with a better name than "Witherable". :-)
Thoughts?
--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/577EF22E.3000705%40garfieldtech.com.
For more options, visit https://groups.google.com/d/optout.