You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Walter Dal Mut edited this page Jan 22, 2017
·
3 revisions
Typically i prefer encapsulation over extensions but if you want to pass around the Corley\Queue\Queue in your application in order to drop-out the proxy whenever you want maybe extensions is more interesting
<?phpuseCorley\Queue\Queue;
class MyService
{
publicfunction__construct(Queue$queue) { }
/** ... */
}
class QueueProxy extends Queue {} // valid as Queue objectclass QueueProxy // not a Queue object
{
publicfunction__construct(Queue$queue) {}
}
If you consider the Queue object as a project boundary probably encapsulation is more interesting.
Encapsulation
If you have a serializer component, you want to abstract queue options and wrap the queue instance, probably encapsulation is more interesting
class QueueProxy
{
publicfunction__construct(Queue$queue, Serializer$serializer) {}
// the send operation uses the serializer to normalize the incoming message object// the receive operation uses the serializer to denormalize the outcoming message representation// the serializer could also be used to normalize options for different queue adapters
}